before someone as this duplicate to this question Can you write nested functions in JavaScript?
I am wondering if we can do something like this?
const toolbar = (props) => {
let sidedrawer = false;
showSideDrawer = () => {
sidedrawer = !sidedrawer
}
return (
<header className={Classes.Toolbar} purchasingHandlerClose={this.showSideDrawer}>
//Something here
</header>
)
}
export default toolbar;
More precisely, something like this in functional component
showSideDrawer = () => {
sidedrawer = !sidedrawer
}
and then calling it like this
<header className={Classes.Toolbar} purchasingHandlerClose={this.showSideDrawer}>
Now, I know we can do this stateful component or class but then again in JS, Class is just syntactical sugar (still trying to figure out the meaning of the phrase), so how can we implement something like this in stateless or functional component?