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
Source: stackoverflow.com
hide show object in react
const Search = () => { const [showResults, setShowResults] = React.useState(false) const onClick = () => setShowResults(true) return ( <div> <input type="submit" value="Search" onClick={onClick} /> { showResults ? <Results /> : null } </div> ) } const Results = () => ( <div id="results" className="search-results"> Some Results </div> ) ReactDOM.render(<Search />, document.querySelector("#container"))
Source: stackoverflow.com
hide react source
In in package.json (Windows) "scripts": { ... "cleanBuild": "rimraf ./build/*", "build": "npm run cleanBuild && set \"GENERATE_SOURCEMAP=false\" && react-scripts build ",