State and Hooks in ReactJS

In React function components, state is used to store data that changes over time. We use the useState Hook to add state to our component. For example, **const [joke, setJoke] = useState("")** creates a state variable joke initialized to an empty string.

The React documentation notes that “useState is a React Hook that lets you add a state variable to your component.”. Whenever we update this state (via setJoke), React re-renders the component to show the new value. This is how the fetched joke text appears in the UI after the button is clicked.