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.

Using setState in afterColumnFilter function

See original GitHub issue

It will crash program after I use setState in afterColumnFilter.

getFilterResult = (f, result) => {
    Promise.resolve(this.somethingComputing(result))
                  .then(data => this.setState({data: data}))
}

render(){
   const options = {
       afterColumnFilter: this.getFilterResult
   }
}

It will call setState many time…

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Terryhungcommented, Sep 5, 2017

@AllenFang Doing some computing for data.

Do you have any suggestion for us to achieve this goal?

1reaction
garrettmurphycommented, Dec 1, 2017

@AllenFang I have a use case for you.

We have been working with react-bootstrap-table v4.0.0-beta.1. We had issues with users of our app selecting multiple rows, then choosing to filter the rows. If they did this, the rows remained selected that were now no longer visible, and if they executed an action on the visible rows that were selected, it would also execute on the rows hidden by the filter.

To avoid this, we have an afterColumnFilter function that sets a property in state, currentFilteredData, storing a record of all the visible selected rows so we only execute commands on those rows.

Now that we are attempting to upgrade to 4.2.0, it’s an infinite loop, as others have experienced. We can store the filter conditions and do a comparison, only setting the state if the conditions have changed, but this seems like a bad workaround for a breaking change.

Read more comments on GitHub >

github_iconTop Results From Across the Web

using setState after function - Stack Overflow
i try it using setState after function in react, first run function , function finished after run setState({example:'example1'}) , how i can ...
Read more >
ReactJS setState() - GeeksforGeeks
Syntax: We can use setState() to change the state of the component directly as well as through an arrow function. setState({ stateName : ......
Read more >
State and Lifecycle - React
This page introduces the concept of state and lifecycle in a React component. You can find a detailed component API reference here.
Read more >
How to become a pro with React setState() in 10 minutes
Whether you declare a Component as a function or a class, it must never modify its own props. All React Components must act...
Read more >
React setState usage and gotchas - ITNEXT
Signature. setState(updater[, callback]). The first argument is an updater function with the signature: ( ...
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