Suppose I have a react component:
class myComponenet extends Component {
state = {
foo: "show",
};
hideit() {
this.setState({
foo: "hide",
});
}
render() {
return (
<div
className={this.state.foo}
onClick={this.hideit}
>
<p>Some thing</p>
</div>
);
}
}
How would I "bind" the class to foo, so that every time foo changes the component updates and rerenders, setting the classname equal to the new value of foo?
Like vuejs does with v-bind:class="foo"