Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent for ng-show and ng-hide in react js?

Tags:

reactjs

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....

like image 258
Manikanta B Avatar asked Sep 08 '17 07:09

Manikanta B


People also ask

How do I show and hide components in Reactjs?

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.

How do you toggle hide and show in react JS?

You can use React to use CSS to hide and show the element just as easily: <div style={{display:this. props. example}}/>.

What is the difference between ngIf and ng-show ng-hide?

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.


1 Answers

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>}
like image 137
Manikanta B Avatar answered Sep 17 '22 15:09

Manikanta B