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.

setState not re rendering in version ^1.0.0

See original GitHub issue

Hi @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:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
waynebrantleycommented, Sep 5, 2018

@AllenFang Thanks!

1reaction
waynebrantleycommented, Sep 2, 2018

@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.

Read more comments on GitHub >

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

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