Skip to content

Instantly share code, notes, and snippets.

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