0.1.6 • Published 3 years ago
p14-mymodal v0.1.6
p14-mymodal
Simple Modal created for HRnet.
Intallation
To install, you can either use npm or yarn:
npm install p14-mymodalyarn add p14-mymodalHow to use
After installing this library, you'll need to use the useState() hook from react:
import React from 'react';
import { useState } from "react";
const [modalDisplay, setModalDisplay] = useState(false);By default, the modal will be hidden as represented by the false boolean set in useState(false), to show it, you'll have to set modalDisplay to true with setModalDisplay(true).
Example
import React from 'react';
import { useState } from "react";
import { render } from "react-dom";
import Modal from "p14-mymodal";
const App = () => {
const [modalDisplay, setModalDisplay] = useState(false);
return <div style={{ width: "100%", display:"flex", justifyContent:"center"}}>
<button onClick={() => setModalDisplay(true)}>Open Modal</button>
<Modal action={() => setModalDisplay(false)} display={modalDisplay} message={"Your message here."}/>
</div>
};
render(<App />, document.getElementById("root"));