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.

Whole table is re-rendered when subcomponent is updated

See original GitHub issue

What version of React-Table are you using?

6.7.4

What bug are you experiencing, or what feature are you proposing?

We implemented a subcomponent based on a mapper in a react redux environment.

First we have a Dashboard component (not connected to Redux store)

export default class Dashboard extends Component {

  render() {
    const data = this.props.data;
    const period = this.props.period;
    const columns = this.props.columns;

    const subComponentMapper = row => {
      return (
        <div>
          <DashboardSubComponents
            period={period}
            diplayedIn={row}
            />
        </div>
      );
    };

    return (
      <div className="dashboard-container">
        <ReactTable
          noDataText="Veuillez patienter pendant le chargement des données..."
          data={data}
          columns={columns}
          defaultPageSize={10}
          className="-striped -highlight"
          SubComponent={subComponentMapper}
          maxLength
          />
        <br/>
      </div>
    );
  }
}

DashboardSubComponents are (when going deeper into implementation) finally some containers containing components. They are to be updated with the redux store in this way:

  • We click on the arrow to unfold the line
  • In the didMont function, some API call is made
  • When the API call is over (dispatch with thunk), the redux store is updated and we want our subcomponent to read props from it.

The problem is:

1- data={data} is NOT linked to the part of the state that is updated by the API call in the subComponents 2 - BUT the whole table is re-rendered, leading to our subcomponent not to show.

My question is thus: is this a wanted behaviour ? Does the whole table is re-rendered when a subcomponent is changed ?

Thanks in advance, I just want to know this before invastigating too much redux-related magic.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
ThomasVuillaumecommented, Nov 29, 2017

@gary-menzel we solved this using, as you suggested:

collapseOnDataChange: false

Thanks for you help, closing !

5reactions
gary-menzelcommented, Nov 28, 2017

This is the default behaviour. Look at the collapse,,,, set of props in the doco to control this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Whole table is re-rendered when subcomponent is updated
We implemented a subcomponent based on a mapper in a react redux ... Whole table is re-rendered when subcomponent is updated #649.
Read more >
Re-rendering Table component when parent passes new or ...
Although the parent component fetches the new data and rerenders, the Table Component does not update to show the new data in the...
Read more >
When does React re-render components? - Felix Gerschau
Force a React component to rerender. Using React's forceUpdate function; Force an update in React hooks. How to optimize re-renders.
Read more >
Improving component's re-render performance | Dimitrios Lytras
We map over this array in order to render a table. Component.tsx ... Each row of the table is a component that holds...
Read more >
Learn how to force react components to rerender without ...
A complete guide on component re-rendering. Here you will learn how to force react components to rerender without calling the set state.
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