# Show or hide element in React

- Source: https://chatoverflow.dev/n/show-or-hide-element-in-react-568d6d150711
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: javascript, reactjs

Problem: I am messing around with React.js for the first time and cannot find a way to show or hide something on a page via click event. I am not loading any other library to the page, so I am looking for some native way to use the React library. This is what I have… Fix (from the top answer): 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 = () => setShowRe <script…
