Infinite loop if initialValue is defined in a SelectArrayInput which is integrated in a formdataconsumer
See original GitHub issueWhat you were expecting: Defined initial values for SelectArrayInput in a FormDataConsumer and have a working environment
What happened instead: An infinite loop take place and stop application.
Steps to reproduce:
- Go to https://codesandbox.io/s/sweet-darkness-15q1m?file=/src/posts.js:1446-1462
- Open your browser inspector
- Go in the integrated browser to post/create
- You should see “Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn’t have a dependency array, or one of the dependencies changes on every render.” in the console
- Choose nom 2 in the first select
- You should see an infinite loop and real browser (firefox at least) ask to stop the process
Related code:
<SimpleForm>
<FormDataConsumer>
{({ formData, ...rest }) => {
return (
<SelectArrayInput
label="User"
source="userId"
initialValue={[1]}
choices={[
{ id: 1, name: "nom1" },
{ id: 2, name: "nom2" },
{ id: 3, name: "nom3" },
{ id: 4, name: "nom4" }
]}
>
<ChipField source="name" />
</SelectArrayInput>
);
}}
</FormDataConsumer>
{/*...*/}
</SimpleForm>
Other information:
Environment
- React-admin version: 3.10.2
- React version: 17.0.1
- Browser: firefox & chrome tested
- Stack trace (in case of a JS error):
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
React hooks depends on another state can cause infinite loop ...
I think it is happening because of useEffect dependency array . In the infinite loop version of useEffect , initialValue is changing ...
Read more >Input Components - React-admin - Marmelab
An Input component displays an input, or a dropdown list, a list of radio buttons, etc. Such components allow to update a record...
Read more >An infinite loop may occur in Ladder Diagram (LD) and ...
When the ISaGRAF runtime is executing in an infinite loop, the controller in which the ISaGRAF runtime is embedded stops scanning inputs and ......
Read more >ra-input-rich-text: Versions - Openbase
Fix <FormDataConsumer> inside <SimpleFormIterator> adds empty value (#8061) (fzaninotto) ... Fix DOM warnings when using <SelectArrayInput> as child of ...
Read more >How to solve the React useEffect Hook's infinite loop patterns
Solve the issue of infinite loops when using the useEffect Hook in React to more smoothly utilize the Hook for your app's side...
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
Nevermind, the original sandbox still shows the issue indeed.
I’m still experiencing this bug as well as of
react-admin@3.16.4
, why is it closed?