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.

Table is not visible when column data is coming from state

See original GitHub issue
  • Versions

“react”: “^17.0.0” “react-dom”: “^17.0.0”,

  • Problem

I am formatting my table data in format required by GridTable in componentDidMount() and then storing it in the react state. Now the problem is that the data is not visible on the table. However, if I serve local column data and continue serving state data to row prop things are working fine. I am not able to understand what is wrong.

While checking the documentation I noticed that there is a prop function named onRowsRequest which handles async row rendering. But I could not find a similar prop function for columns.

For your reference this is how my render function looks like <GridTable columns={this.state.columns} rows={this.state.rows} />

image

  • Little hack

As I was trying to figure out what is wrong, I found that using onColumnsChange props is kind of solving the problem. All I did was <GridTable onColumnsChange={this.handleColumnChange} columns={this.state.columns} rows={this.state.rows} /> and handleColumnChange = (event) => { return event; };.

However, this is not a props fix as I can not change column visibility and move columns.

Any help will be really appreciated. Thank you in advance.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
manmohitgrewal1commented, Jan 28, 2022

It worked! Thanks a lot @NadavShaar

1reaction
NadavShaarcommented, Jan 28, 2022

The issue is that the table cannot be mounted without any columns, why not initialize the state with the data instead of waiting it to mount empty?

constructor(props) {
    super(props);
    this.state = {
      rows: this.createTableRows(),
      columns: this.createTableColumns()
    };
  }

And you can skip the componentDidMount lifecycle.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React table column not displaying data - Stack Overflow
I am using React Table and I am trying to make my table clickable to link to a page different for reach row....
Read more >
My form or report does not display all of the data that I expect ...
The form or report will always show the filtered view of the underlying table or query. Cause. There is a feature designed to...
Read more >
Task State column in Requests not showing values
Solved: Hi SNC, For some reason the Task State column in My Requests list view will not show me the values of the...
Read more >
Why column headers are not showing.When I perfrom column ...
I just perform column hide and show. And moved to another tab and come back to same tab. Its giving error like this.Please...
Read more >
Adding a column to a table where it is not visible.
If you can't add it using personalization, the only way is to do development. If you don't know to do dev or design,...
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