diff --git a/docs/example-react-modal.mdx b/docs/example-react-modal.mdx index 9bccf105a..5ad2770cb 100644 --- a/docs/example-react-modal.mdx +++ b/docs/example-react-modal.mdx @@ -4,32 +4,18 @@ title: Modals --- ```jsx -import React, {useEffect} from 'react' -import ReactDOM from 'react-dom' -import {render, fireEvent} from '@testing-library/react' +import React from 'react' +import { render, fireEvent } from '@testing-library/react' -const modalRoot = document.createElement('div') -modalRoot.setAttribute('id', 'modal-root') -document.body.appendChild(modalRoot) - -const Modal = ({onClose, children}) => { - const el = document.createElement('div') - - useEffect(() => { - modalRoot.appendChild(el) - - return () => modalRoot.removeChild(el) - }) - - return ReactDOM.createPortal( +const Modal = ({ onClose, children }) => { + return (