“Warning: react-modal: App element is not defined. Please use `Modal.setAppElement(el)` or set `appElement={el}`”

后端 未结 12 1400
轻奢々
轻奢々 2021-02-07 03:36

How to fix this warning in console of a React app using the react-modal package:

Warning: react-modal: App element is not defined. Please use Moda

12条回答
  •  半阙折子戏
    2021-02-07 04:11

    Some solutions are given in react-modal issue #133:

    The problem lies here: Depending on when it evaluates react-modal@1.6.5:/lib/helpers/ariaAppHider.js#L1:

    • document.body does not exist yet and it will resolve to undefined || null.
    • if Modal.setAppElement() is called with null or not called at all with the
提交回复
热议问题