Problem: React Hook "React.useEffect" is called in function "selectmenu" which is neither a React function component or a custom React Hook function.
Target: I want to Mount Component('component DidMount/WillUnmount) (using useEffect()) only when I click on a button, rather than, mounting while the file (or whole Component) is being loaded.
Actual Goal: I want to select(or highlight) a file (custom ) on click. But when the user clicks outside the dimensions of the file (), then the selected file should get deselected (remove highlight).
export default function Academics() {
let [ ismenuselected, setmenuselection] = useState(0)
const selectmenu = () => {
console.log("Menu to Select")
React.useEffect(() => {
console.log('Component DidMount/WillUnmount')
return () => {
console.log('Component Unmounted')
}
}, [isfolderselected]);
}
return (
<div onClick={selectmenu}></div>
)
}
Note: