Created
October 27, 2021 07:08
-
-
Save hieptl/964fa542e44bc3b0fad4fda0c0acab94 to your computer and use it in GitHub Desktop.
modal.js - Encrypted Chat App
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