question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

rowInfo is returned as undefined with getTrProps

See original GitHub issue

What 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:closed
  • Created 6 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
gary-menzelcommented, Jan 5, 2018

Here’s a quick codesandbox example (based of the Simple Table example in the doco)…

https://codesandbox.io/s/k3q43jpl47

5reactions
gary-menzelcommented, Jan 5, 2018

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 as undefined. So, if you are going to use the data from rowInfo you have to check it first. If it is undefined, then just return {} otherwise you should be fine with the return statement you have - assuming your row has a status element on it (note: row is the displayed row and original 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.

if(rowInfo) /* your return here */
else return {}
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found