rowInfo is returned as undefined with getTrProps
See original GitHub issueWhat version of React-Table are you using?
I’m using the v6.7.5
What bug are you experiencing, or what feature are you proposing?
Using the example in the docs for dynamic styling, rowInfo is returning undefined. My data is provided by a prop from the redux store (it works fine when rendering the table without trying the dynamic styling).
getTrProps={(state, rowInfo) => {
console.log(rowInfo);
return {
style: {
background: rowInfo.row.status === "unresolved" ? 'green' : 'red'
}
}
}}
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
rowInfo is returned as undefined with getTrProps #725 - GitHub
My data is provided by a prop from the redux store (it works fine when rendering the table without trying the dynamic styling)....
Read more >how to have 2 different events for a single row in react-table
I am using getTrProps() component decorator to perform the on click ... rowInfo) => { if (rowInfo && rowInfo.row) { return { onClick:...
Read more >react-table - npm
Fully-resolved state of the table; The standard table generator; The instance of the component. You can then return any JSX or react you...
Read more >[Solved]-Select row on click react-table-Reactjs
I found the solution after a few tries, I hope this can help you. Add the following to your <ReactTable> component: getTrProps={(state, rowInfo)...
Read more >React-table-v6 NPM
pivotId || filter.id return row[id] !== undefined ? ... be green if its (row.age > 20) <ReactTable getTrProps={(state, rowInfo, column) => { return...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Here’s a quick codesandbox example (based of the Simple Table example in the doco)…
https://codesandbox.io/s/k3q43jpl47
Maybe I wasn’t clear.
getTrProps
is used inside the code in a number of places and, in at least one of those places,rowInfo
is passed asundefined
. So, if you are going to use the data fromrowInfo
you have to check it first. If it is undefined, then justreturn {}
otherwise you should be fine with the return statement you have - assuming yourrow
has astatus
element on it (note:row
is the displayed row andoriginal
is your original data - which will have everything, not just the data you are displaying).So, there is nothing wrong with your concept. You just have to ensure that
rowInfo
is defined before trying to acecss it. e.g.