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.

v7: changes to flexRender causes component remount

See original GitHub issue

In https://github.com/tannerlinsley/react-table/commit/4f13f3202398c05d642c9f03dc03046aaa7a105b the definition of flexRender changed and you stopped passing props to certain function components. This in turn causes components to be recreated when they don’t need to be, in turn causing them to start off with their initial state values.

Specifically I’m seeing this in a cell renderer, implemented as a callback (wrapped by useCallback) that returns a button-menu, that in turn references table state.

As an aside, this same change also blocks defining renderers as raw JSX.

i.e.

you used to be able to define a Column with something like:

Header: <Trans>Name</Trans>

now you must define them as:

Header: () => <Trans>Name</Trans>

I could live with the second side effect, it was a bit wordy, but harmless, the former problem is a blocker.

I’ve tested that simply reverting the change to this function appears to work in general, and specifically fixes my problem.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
tannerlinsleycommented, Aug 15, 2019

Can you point me to a sandbox with an example? That will help me hack on this with you.

0reactions
tannerlinsleycommented, Aug 19, 2019

Awesome! Good to hear.

Read more comments on GitHub >

github_iconTop Results From Across the Web

v7: changes to flexRender causes component remount · Issue ...
This in turn causes components to be recreated when they don't need to be, in turn causing them to start off with their...
Read more >
react-table v7 always remount? - Stack Overflow
This of course causes my stateful components to be remounted and re-initialised. I'm in limbo trying to reason about why this happens. It...
Read more >
Avoid unnecessary remounting of DOM elements in React
I ran into a strange problem while trying to use React's built-in animation API to fade in/out DOM elements when they enter/exit the...
Read more >
Preventing Unmounting / Remounting? : r/reactjs - Reddit
HOWEVER, this causes a change in props to the parent App; this causes all child components to re-render, resetting the state in `<Component...
Read more >
How to remount a React component when a prop changes
To remount a component when a prop changes, use the React key attribute as described in this post on the React blog: When...
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