Is there an equivalent for ng-show
and ng-hide
in react.js?
<input type="checkbox" ng-model="myVar">
<div ng-show="myVar">
<h1>Welcome</h1>
<p>Welcome to my home.</p>
</div>
In Angular the above code works very well, but i'm trying to do this using react i'm not able to find an equivalent....
Hence, props can also be used to hide or show a component. For example, if we pass props, based on the props value, we can hide or show the elements, just like in the below example. Here in this example, the props we have declared is called showHideDemo1 along with the state value.
You can use React to use CSS to hide and show the element just as easily: <div style={{display:this. props. example}}/>.
Basic Difference between ng-if, ng-show and ng-hideng-if can only render data whenever the condition is true. It doesn't have any rendered data until the condition is true. ng-show can show and hide the rendered data, that is, it always kept the rendered data and show or hide on the basis of that directives.
Finally, it has worked after an hour of search using the conditional expression like this:
{!myVar && <div>
<h1>Welcome</h1>
<p>Welcome to my home.</p>
</div>}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With