Created
January 9, 2022 08:40
-
-
Save hieptlccc/5aee01962235de7075233b014fa326c3 to your computer and use it in GitHub Desktop.
modal.js - webex clone
This file contains 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