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 form doesn't re-render on chaning model in props (react)

See original GitHub issue

Are 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
andrewtelnovcommented, Feb 26, 2020

@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

0reactions
ruby0888commented, Feb 28, 2020

@andrewtelnov The issue is fixed! Thank you!

Read more comments on GitHub >

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

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