Survey form doesn't re-render on chaning model in props (react)
See original GitHub issueAre you requesting a feature, reporting a bug or asking a question?
There is some problem I suppose, perhaps a bug or another way to use functionality.
What is the current behavior?
When I get json from back-end survey doesn’t re-render and show nothing. Just empty survey form with typical span.
What is the expected behavior?
I want to request json from db and then implement it into survey model. This way works with 1.1.8 version but doesn’t work with >1.1.24 (or another, I’m sure only about 1.1.8 version). Could you explain please, is it a bug or there is another way to do it?
Provide the test code and the tested page URL (if applicable)
Test code
const App: React.FC = () => {
const [model, setModel] = useState<SurveyModel>(new (Survey as any).Model());
useEffect(() => {
axios.get('someURL')
.then((response) => {
setModel(new (Survey as any).Model(JSON.stringify(response.data)));
console.log(response.data);
})
}, []);
return (
<div className="App">
<Survey.Survey
model={model}
onComplete={(sender: SurveyModel) => console.log('complete survey form')}
/>
</div>
);
};
Specify your
Mozila firefox 60.9.0esr React application react-survey versions: 1.1.8 and 1.1.24
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Why React component doesn't re-render (change styles) when ...
The reason I figured out is that its state doesn't change even when prop isSelected changes. I don't know why this happens. Does...
Read more >Render Props - React
The term “render prop” refers to a technique for sharing code between React components using a prop whose value is a function. A...
Read more >When does React re-render components? - Felix Gerschau
Why doesn't my React component update when its props change? ... we need to understand what the DOM (Document Object Model) is:.
Read more >React re-renders guide: everything, all at once - Developer way
In order for props to change, they need to be updated by the parent component. This means the parent would have to re-render,...
Read more >Creating Dynamic Forms With React Hooks - Aaron Powell
The component will receive the formData as a prop, so it's up to the parent component to work out how to get the...
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 FreeTop 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
Top GitHub Comments
@Vladqqqqoo @RixBai The issue is fixed. The fix will be available in the next minor update (v1.5.11) that we will release on this week.
Thank you, Andrew
@andrewtelnov The issue is fixed! Thank you!