If I have a React component and I want to hide it. At the moment, I am taking two approaches:
The state management way
render() {
return (
<div>
{ this.state.showComponent && <Component/> }
</div>
);
}
The CSS way:
render() {
return (
<div>
<Component className="hide-with-CSS"/>
</div>
);
}
I assume that the former way will remove/add the component based on the current state while the latter way just "hides" it. So my questions are:
- Which method would produce a better performance?
- Is there another way to efficiently hide an element?