setState not re rendering in version ^1.0.0
See original GitHub issueHi @AllenFang
I have a function which simply sets the state of a variable, based on the row index. Version 1.0.0 works perfectly with the code. But when I installed the new version ^1.0.0, it somehow stops rendering. It sets the state of the variable, but doesn’t re render. I will provide some code snippets to back this issue.
Note : Basically the column formatter method is not getting called. (No error in console)
Thanks The div that has a onClick handler:
<div
role="button"
tabIndex="0"
onKeyDown={() => this.handleSettings(rowIndex)}
className={gearIconWrapper ${showGearOptions}}
onClick={() => this.handleSettings(rowIndex)}
>
The function that’s setting the state, but not re rendering :
this.handleSettings = this.handleSettings.bind(this);
handleSettings(rowIndex) { this.setState({ activeIndex: rowIndex, }); }
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
React is not re rendering after setState is called, why? [closed]
First of all the usage of this.setState is wrong. setState is a function you should call it not assign something to it.
Read more >When does React re-render components? - Felix Gerschau
As we already saw before, React re-renders a component when you call the setState function to change the state (or the provided function...
Read more >Why React doesn't update state immediately - LogRocket Blog
In React, every state update causes the component being updated to re-render. Because re-rendering is an expensive operation, making state ...
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 >React doesn't always trigger a re-render on setState
For new React developers, it is common to think that setState will trigger a re-render. But this is not always the case. If...
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

@AllenFang Thanks!
@AllenFang thanks for fixing. Of note - if there are several dummy or calculated columns, we have to make up ‘fake field names’ as you require the field names to be unique. So only one “” column is allowed.
Additionally, you could add an optional ‘shouldCellUpdate’ for a column - you could pass current and next row into it…we could return true/false based on whatever logic - thereby optimizing the rendering.