Challenge: useState HookChallenge: useState Hook

Task 1

Create a component that includes a button and a text paragraph. Implement the necessary logic using the useState hook to toggle the visibility of the text paragraph when the button is clicked.

The task is:

  1. Import the correct hook from the React library.
  2. Set the correct state variable taking in account the function name.
  3. Use the reference to the function to react on the button click.
1. To import the appropriate hook from the React library, include an import statement.

2. For this task, we will utilize the useState hook as we are managing the state of paragraph visibility.

3. To determine the appropriate variable name for the state, observe the function associated with setting the state setIsVisible. Remove the "set" prefix and use a lowercase first letter for the variable name.

4. To invoke the function when the button is clicked, assign the function name as the value for the onClick attribute.

Everything was clear?

Section 3. Chapter 3