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

useRowState seems to have a logical error #2102

Closed
bradennapier opened this issue Apr 5, 2020 · 2 comments
Closed

useRowState seems to have a logical error #2102

bradennapier opened this issue Apr 5, 2020 · 2 comments
Labels
critical Issues or bugs that are highly critical and must be solved as soon as possible. released

Comments

@bradennapier
Copy link

Since I am clearly just showing in your code exactly where the issue is, skipping the template there.

At the moment using the useRowState seems to have some bugs in the initialAccessor logic for both row and cell states.

https://github.com/tannerlinsley/react-table/blob/master/src/plugin-hooks/useRowState.js#L156

Documentation says:

initialRowStateAccessor: Function(originalRow) => Object<any>
Optional
Defaults to: row => ({})
This function should return the initial state for a row.
If this function is defined, it will be passed a Row object, from which you can return a value to use as the initial state, eg. row => row.original.initialState
initialCellStateAccessor: Function(originalRow) => Object<any>
Optional
Defaults to: cell => ({})
This function should return the initial state for a cell.
If this function is defined, it will be passed a Cell object, from which you can return a value to use as the initial state, eg. cell => cell.row.original.initialCellState[cell.column.id]

So while the type shows originalRow - the description indicates it would give the row or cell object (which is probably what it should be since its fairly useless for every sell to get the original row without knowing any information about itself even anyway. That should only be executed a single time if that is the case.

Seems that both the row and cell should indeed receive the row or cell object as the docs indicate rather than the raw originalRow value being sent. At this point I can not see any purpose to using initialCellStateAccessor

@picosam
Copy link

picosam commented Jun 15, 2020

Hello @tannerlinsley, is this a verified bug?

@tannerlinsley tannerlinsley added the critical Issues or bugs that are highly critical and must be solved as soon as possible. label Aug 3, 2020
ivaskevych added a commit to ivaskevych/react-table that referenced this issue Sep 9, 2020
…initialCellStateAccessor`

pass `row` / `cell` to `initialRowStateAccessor` / `initialCellStateAccessor` accordingly

closes(TanStack#2102, TanStack#2701)
ivaskevych added a commit to ivaskevych/react-table that referenced this issue Sep 9, 2020
…initialCellStateAccessor"

pass "row" / "cell" to "initialRowStateAccessor" / "initialCellStateAccessor" accordingly

closes(TanStack#2102, TanStack#2701)
tannerlinsley pushed a commit that referenced this issue Oct 4, 2020
…initialCellStateAccessor" (#2719)

* fix(usepagination resetpage on globalfilter change): pageIndex reset

autoReset pageIndex on globalFilter change

"fix #1812"

* fix(useRowState): change argument for `initialRowStateAccessor` and `initialCellStateAccessor`

pass `row` / `cell` to `initialRowStateAccessor` / `initialCellStateAccessor` accordingly

closes(#2102, #2701)

* fix(useRowState): change argument for "initialRowStateAccessor" and "initialCellStateAccessor"

pass "row" / "cell" to "initialRowStateAccessor" / "initialCellStateAccessor" accordingly

closes(#2102, #2701)
@tannerlinsley
Copy link
Collaborator

🎉 This issue has been resolved in version 7.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
critical Issues or bugs that are highly critical and must be solved as soon as possible. released
Projects
None yet
Development

No branches or pull requests

4 participants