Don't know how to render a select component, when im fetching both value & options from api?
Unanswered
shor posted this in #help-forum
shorOP
- fetching data from the api using fetch api
- set the form data using form.setValue() in a useEffect
- the select inputs in the form shows the correct value in the initial render
- if I refresh the page the select input gets reset while the other inputs in the form show the correct data
- set the form data using form.setValue() in a useEffect
- the select inputs in the form shows the correct value in the initial render
- if I refresh the page the select input gets reset while the other inputs in the form show the correct data
8 Replies
shorOP
the select options are being fetched from another api and when the options are rendered the value of the field gets reset to an empty string
this is one of the rare occasions when the select input is rendered correctly
the no. is the render count and the object is the form state
@shor this is one of the rare occasions when the select input is rendered correctly
shorOP
here the component rendered only 6 times
here as you can see that the form has the empno [ EMP001 ] is in its state but the Select input is not being rendered correctly
- it should show the selected value
- also the render count went to 16 from 6