Answers for "how to hide content in react js code"

2

react hide source code

in package.json file as follows.
add GENERATE_SOURCEMAP=false to build

scripts: {
"build": "GENERATE_SOURCEMAP=false react-scripts build"
}
Posted by: Guest on October-23-2020
1

react hide element

React circa 2020
In the onClick callback, call the state hook's setter function to update the state and re-render:

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"))
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.13.1/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.13.1/umd/react-dom.production.min.js"></script>

<div id="container">
  <!-- This element's contents will be replaced with your component. -->
</div>
Posted by: Guest on March-20-2021

Code answers related to "how to hide content in react js code"

Code answers related to "Javascript"

Browse Popular Code Answers by Language