This is a popup component for React.js. It is modularized and easily scalable.
- pState: must be a state variable of boolean such as: "const [popup_state, setPopupState] = useState(false)".
- setPState: must be a set state function for pState, so that the "X" button may close the popup when clicked.
- props.children: contents enclosed between will be displayed inside popup window.
import Popup from "./Popup.js";
import "./Popup.css";
function Home(){
const [popup_state, setPopupState] = useState(false);
return(
<Popup pState={popup_state} setPState={setPopupState}>
<h1>This is a Test modal</h1>
</Popup>
);
function func(){
//some code to control popup_state
}
}