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

后端 未结 12 1387
轻奢々
轻奢々 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:19

    If getting the Warning: react-modal: App element is not defined... error when running tests (we were running Jest), you can suppress the warnings by adding the following to your test file:

    import ReactModal from 'react-modal';
    ReactModal.setAppElement('*'); // suppresses modal-related test warnings.
    

提交回复
热议问题