Skip to content

React 18 StrictMode #738

@lasseklovstad

Description

@lasseklovstad

Hey! I'm having an issue opening my custom modal with FocusTrap in StrictMode after upgrading to React 18. When the modal state is opened onDeactive is called immediately (probably because of the double render in Strictmode), which closes the dialog.
I see you have recently released a fix for StrictMode but it doesn't fix this issue.

I made a demo where i just copied the example from: demo/js/demo-special-element.js

The change i made in the demo is to only render the FocusTrap element when it is active.

Code sandbox demo: https://codesandbox.io/s/0vhfsb

Is this a bug or should i implement it differently?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions