Williams Williams -4 years ago 128
Android Question

Invisible View in ReactJS

I am trying to make hidden

view
as like android has. This occupies the space but it doesn't show to the user.

<View
android:id="@+id/hiddenView"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:visibility="invisible" />


What is the way to do this in
ReactJS
?

Answer Source

You can use visibility set to hidden in the style of your html element in your react component. See example below.

function InvisibleDiv() {
  return <div style={{width: '50', height:'50', backgroundColor: 'red',visibility: 'hidden'}}></div>;
}

ReactDOM.render(<InvisibleDiv />, document.getElementById('app'))
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="app"></div>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download