Skip to content

Parent context is inaccessible inside a modal created with react-modal-hook #30

@firxworx

Description

@firxworx

I am experiencing an issue where a parent provider's context is inaccessible inside a modal created with the useModal() hook. I don't think this should be an issue because React portals can preserve context.

See the following codesandbox for an example of this issue:
https://codesandbox.io/s/formik-typescript-material-ui-react-modal-hook-nrz24

The codesandbox features a parent component that uses formik to manage the state of a form. Form context is provided by the parent Formik component. Children of the Formik component such as Field or FastField (or any component that uses the useFormikContext() hook) can access the form context.

However, if I try to access the formik context in a component that's inside of a modal created with react-modal-hook, it is not available.

I ruled out the TransitionGroup factor by replicating this issue in a non-animated modal.

I can eliminate the issue if I ditch react-modal-hook and use the Material UI dialogs directly.

Thanks for your work on this library, it is being used in production in a couple of my projects :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions