Syncing react query data with useState state
Hi all, I have a provider which is fetching a list of "KeyRecord" from the backend.
This provider provides the state of a list of forms, each form allows to edit a single KeyRecord.
When the provider is done fetching the list of KeyRecord from the backend, it needs to initialize the state of the forms.
The problem is, because I do that with a useEffect, there is a small timeframe where isLoading is false, and keyRecordsFormState is an empty array [] and I would like to get rid of that because it causes an unnecessary render of the consumers with an empty list.
Code:
This provider provides the state of a list of forms, each form allows to edit a single KeyRecord.
When the provider is done fetching the list of KeyRecord from the backend, it needs to initialize the state of the forms.
The problem is, because I do that with a useEffect, there is a small timeframe where isLoading is false, and keyRecordsFormState is an empty array [] and I would like to get rid of that because it causes an unnecessary render of the consumers with an empty list.
Code: