final-form / react-final-form

🏁 High performance subscription-based form state management for React
https://final-form.org/react
MIT License
7.38k stars 480 forks source link

Warning: Cannot update a component (`Title`) while rendering a different component (`FormSpy`) #828

Open kopax opened 4 years ago

kopax commented 4 years ago

Are you submitting a bug report or a feature request?

Bug

What is the current behavior?

When trying to reading the state from redux after saving it in redux, I have :

index.js:1 Warning: Cannot update a component (`Title`) while rendering a different component (`FormSpy`). To locate the bad setState() call inside `FormSpy`, follow the stack trace as described in https://fb.me/setstate-in-render
    in FormSpy (at FormStateToRedux.js:8)
    in FormStateToRedux (at CreatePromotionForm.js:308)

What is the expected behavior?

I expect no erros

Sandbox Link

Just use a component that is having

<>
 <Form>
    <FormSpy name="form" />
    <Field name="title" />
 </Form>
 <TitleFromRedux />
</>

What's your environment?

    "react": "^16.13.1",
    "react-native": "file:expo/react-native-sdk-36.0.1.tar.gz",
    "final-form": "^4.19.1",
    "final-form-arrays": "^3.0.2",
    "react-final-form": "6.5.0",
    "react-final-form-arrays": "^3.1.1",
    "react-native-final-form-material": "^1.0.14",
gertdreyer commented 1 year ago

Please see https://github.com/final-form/react-final-form/issues/985#issuecomment-1363973861