here in my code i m toggling a panel on the basis of click event when clicked it will show and when again clicked on the same button it will disappear. but what i want when i will click outside the button anywhere the panel should close, how do i do that?
function Project(props) {
    const [rightPanel, setrightPanel] = useState(false);
    function projectToggle () {
        if(!rightPanel) setrightPanel(true);
        else setrightPanel(false);
        }
    return (
        <React.Fragment>
            <div className="vh-ce-align pd-b-10 mg-b-5 bo-bottom-grey">
                <div className="button-blue" onClick={projectToggle}>Create New Project</div>
            </div>
            <div className="d-flex">
                
                {rightPanel ? (<div className="right-side-panel">
                    <div className="mg-b-20">
                        <div className="fw-bold mg-b-10">Client Id</div>
                        <input type="text" className="right-side-input"/>
                    </div>
                    <div className="mg-b-20">
                        <div className="fw-bold mg-b-10">Frequency</div>
                        <div className="wd-pct-100 d-flex pd-b-5 bo-bottom-grey">
                            <div className="flex-one">Annually</div>
                            <i className="fas fa-chevron-down mg-r-10"></i>
                        </div>
                    </div>
                    <div className="mg-b-20">
                        <div className="fw-bold mg-b-10">Year</div>
                        <div className="wd-pct-100 d-flex pd-b-5 bo-bottom-grey">
                            <div className="flex-one">Select Year</div>
                            <i className="fas fa-chevron-down mg-r-10"></i>
                        </div>
                    </div>
                </div>): null}
            </div>
        </React.Fragment>
    )
}
 
     
    