Course Content
Mastering React
1. Introduction to React
What is React?Web Application ArchitecturesVirtual DOM and Browser DOMJSXRender Element to DOM TreeChallenge: Render ElementComponentsChallenge: Functional ComponentsConditional RenderingChallenge: Render Content ConditionallyRender a Data CollectionChallenge: Render Collection"Introduction to React" Section Sum Up
Mastering React
Challenge: 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:
- Import the correct hook from the React library.
- Set the correct state variable taking in account the function name.
- Use the reference to the function to react on the button click.
Hint
1. To import the appropriate hook from the React library, include an
2. For this task, we will utilize the
3. To determine the appropriate variable name for the state, observe the function associated with setting the state
4. To invoke the function when the button is clicked, assign the function name as the value for the
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