Last active
November 22, 2021 12:00
-
-
Save hieptl/83506a08eb9ba307a63167a153106fde to your computer and use it in GitHub Desktop.
Modal.js - Discord Clone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from 'react'; | |
const withModal = ModalComponent => WrapperComponent => { | |
return function () { | |
const [isModalShown, setIsModalShown] = useState(false); | |
return ( | |
<> | |
<WrapperComponent toggleModal={setIsModalShown}/> | |
{isModalShown && <ModalComponent toggleModal={setIsModalShown} />} | |
</> | |
) | |
} | |
} | |
export default withModal; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment