Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot access to row's index in renderRow of List #2825

Closed
kenji4569 opened this issue Jul 29, 2019 · 8 comments · May be fixed by actionhero/actionhero-react-native-example#33
Closed

Cannot access to row's index in renderRow of List #2825

kenji4569 opened this issue Jul 29, 2019 · 8 comments · May be fixed by actionhero/actionhero-react-native-example#33

Comments

@kenji4569
Copy link

This commit a867e33#diff-adb80937e3be06283394efe72848a734
changes the behavior of the renderRow of List.
Then we can no longer access to the index of each row.
It's ok to change the behavior but we should access to the index anyway.

@kenji4569
Copy link
Author

I could manage to access index of each row by passing "renderItem" to List as follows:

<List dataArray={items}
        {
          ...{
            renderItem: ({item, index}) => {
              return <ListItem key={index}>{'xxx'}</ListItem>
            },
          }
        }
        />

But it would be better to define renderItem explicitly to the props of List.

PlabanJr added a commit that referenced this issue Jul 29, 2019
@kenji4569
Copy link
Author

It might be better to keep backwards compatibility for renderRow's spec, then define a renderItem method explicitly for it.

@sankhadeeproy007
Copy link
Contributor

@kenji4569 Yes, that's what has been done in the above commit. We can now access the index from renderRow as well.

@kenji4569
Copy link
Author

@sanketsahusoft
I think previous renderRow's arguments are (rowData, secId, rowId), not (item, index), which would break the backwards compatibility.

@sankhadeeproy007
Copy link
Contributor

Oh okay, does FlatList provide (rowData, secId, rowId)?
Care to send a PR with the fixes above?

@kenji4569
Copy link
Author

kenji4569 commented Jul 29, 2019

does FlatList provide (rowData, secId, rowId)?

I think no.
Maybe we should set as follows:

renderItem={({ item, index }) => this.props.renderItem ? renderItem({ item, index }) : this.props.renderRow(item, 0, index)}

PlabanJr added a commit that referenced this issue Jul 29, 2019
PlabanJr added a commit that referenced this issue Jul 29, 2019
@kenji4569
Copy link
Author

@PlabanJr
I think we should also fix index.d.ts for the props change.

@PlabanJr
Copy link
Contributor

PlabanJr commented Aug 2, 2019

@PlabanJr
I think we should also fix index.d.ts for the props change.

It's done 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants