There is some problem I suppose, perhaps a bug or another way to use functionality.
When I get json from back-end survey doesn't re-render and show nothing. Just empty survey form with typical span.
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?
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>
);
};
Mozila firefox 60.9.0esr
React application
react-survey versions: 1.1.8 and 1.1.24
@Vladqqqqoo We can do some changes in react version. I remember we removed some obsolete react functions and change the way we are working with react state, according to react docs.
Does your render call on changing the model? Do you change SurveyJS version only?
Thank you,
Andrew
@andrewtelnov
Yes, I have changed only react-survey version. "Does your render call on changing the model?" - what exactly do you mean?
@Vladqqqqoo I have created the example with v1.1.29 and it works just fine for me.
Thank you,
Andrew
@ andrewtelnov
I'm sorry for late answer.
You used 1.1.1 version of "survey-react". Please have a look again.
I have tried the latest version of survey (1.5.0) and the result is the same.
So, really need your help, because it still doesn't work.
Thanks!
And pay attention please:
I do not keep a JSON on front-end part. I fetch it from back-end in componentDidMount and then setup new model with this JSON.
Do not add conditional render, because there's can be situation when it's inappropriate. For example if you have to change your survey model several times
@andrewtelnov Still waiting your recommendations
@Vladqqqqoo We are having same problem.
Did you find the solution?
@Vladqqqqoo @RixBai I have found the problem. We did not update correctly new props when new model or json is coming. We will work on the fix.
Thank you,
Andrew
@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!
Most helpful comment
@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