-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't perform a React state update on an unmounted component. #1217
Comments
Also just ran into this. Except: react 16.6.3 and yarn 1.12.3. |
Can you create a sandbox with your example? |
Also just ran into this after previously not having issue. |
Getting the same error with Form.js const Form = () => (
<Formik initialValues={{ name: 'test' }}>
{({ handleChange, values }) => (
<input
data-testid="name"
name="name"
onChange={handleChange}
value={values.name}
/>
)}
</Formik>
) Form.test.js test('test', async () => {
const { getByTestId } = render(<Form />)
fireEvent.change(getByTestId('name'), { target: { value: 'asdf' } })
}) |
@jaredpalmer I'll create sandbox example asap, just not having the time now. :( |
@tu4mo or anyone else have you had any luck? I'm running into the same issue right now. |
I found the solution here |
|
I'm not using this in a test context, wondering where the |
I have this problem too. The For example, I have a specific test that when I click on submit button and there are some error in the form, I want to be sure that the backend is not called. I just expect for the |
You just run that assertion after the wait
or if you don't have async/await
|
|
Here the basic codesandbox with the Formik site's example. You can realize the error on the console after running the tests. |
@lourenci have you tried with 1.4.3? |
The issue is due to how Formik's submit is async but the browser's submit event is sync. This makes it very challenging if not impossible to test directly. |
🐛 Bug report
Current Behavior
When component is unmounted for any reason and a pending formik workflow is still pending an error message shows up:
Expected behavior
No error
Reproducible steps
1 - Create a simple formik form.
2 - Make a submit event and change view right after. In my case I'm just redirecting the user to another route due to a non-authorized request.
Versions
This is might be related:
#772
The text was updated successfully, but these errors were encountered: