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.

Survey stops working after call to setState

See original GitHub issue

Are you requesting a feature, reporting a bug or asking a question?

Bug report, example is attached.

What is the current behavior?

https://next.plnkr.co/edit/ZzdpwCcEQNOQIMjY

If item2 in question2 is selected, then the navigation does not change and question3 stays hidden. This occurs after the call to setState in componentDidMount

What is the expected behavior?

https://next.plnkr.co/edit/jkXmKgYyTJ8HVon5

After selecting item2 in question2 the survey should reveal question3 and the navigation should show the next page.

How would you reproduce the current behavior (if this is a bug)?

With setState: https://next.plnkr.co/edit/ZzdpwCcEQNOQIMjY Without setState: https://next.plnkr.co/edit/jkXmKgYyTJ8HVon5

Specify your

  • browser: Chromium
  • browser version: 71
  • surveyjs platform: react
  • surveyjs version: 1.0.32 - 1.0.65

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
shehrozsheikhcommented, Nov 27, 2020

I am still getting this issue while calling any of the React Hook setters.

1reaction
dennisfischercommented, Jan 25, 2019

@andrewtelnov I found a “workaround”, which outlines another or related problem.

https://next.plnkr.co/edit/5q3MP9eY4HDz4ZFI

This forces the child element (i.e., the survey) to reinitialize. Then, the navigation works. However, now the unmounted survey is still alive as we can see in the console (setState is called on an unmounted component).

Read more comments on GitHub >

github_iconTop Results From Across the Web

react setState seems to be cancelled by redux dispatch?
So the multiple mapDispatchToProps calls and seeming ignore of setState was due to a new child component re instantiating.
Read more >
Lifting State Up - React
When the temperature was in the local state, the TemperatureInput could just call this.setState() to change it. However, now that the temperature is...
Read more >
How to Bring Reactivity into React with States - freeCodeCamp
When the Survey updates its state (calls setState ), the render function triggers. If so, it sends a request for Question rendering (details ......
Read more >
ReactJS setState() - GeeksforGeeks
setState is asynchronous call means if synchronous call get called it may not get updated at right time like to know current value...
Read more >
This.setstate not working in react js - CodeProject
when click on Toggle Person button following error occurred: index.js:1437 Warning: Can't call setState on a component that is not yet ...
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