Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

How to hide component in React

import React, { useState } from 'react';

const Component = () => {
  const [show, setShow] = useState(false);
  return(
    <>
      <button onClick={() => setShow(prev => !prev)}>Click</button>
      {show && <Box>This is your component</Box>}
    </>
  );
}

export default Component
Comment

how to hide a button in react

{ this.state.showMyComponent ? <MyComponent /> : null }

{ this.state.showMyComponent && <MyComponent /> }
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to delete object in array 
Javascript :: how to make an if statement in javascript 
Javascript :: reverse () method to reverse the array 
Javascript :: javascript strings 
Javascript :: javascript list comprehension 
Javascript :: how to make pdf of web page 
Javascript :: Prerequisites before creating react-app 
Javascript :: aws lambda function setup for node js 
Javascript :: best method to convert string to upper case manually 
Javascript :: add new field using update in mongoose 
Javascript :: jquery or operator 
Javascript :: jquery get element attribute 
Javascript :: nodejs cluster 
Javascript :: sails js 
Javascript :: how to add class in jquery 
Javascript :: how reducer works in redux 
Javascript :: js int 
Javascript :: validate decimal number with 6 decimal digits javascript 
Javascript :: js oop 
Javascript :: javascript split array 
Javascript :: javascript function with array parameter 
Javascript :: javascript sandbox 
Javascript :: firebase contains query realtime 
Javascript :: date and month are swapping in angular 
Javascript :: html check template browser 
Javascript :: javascript moving text from left to right onscroll 
Javascript :: subdomain react app 
Javascript :: npm ln 
Javascript :: tomtom map in vuejs 
Javascript :: ex:javascript array 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =