- We call the useState Hook in our component , with the name of the variable and its initial state as an argument :
- To change the status of the variable we use the setter function, inside the event click :
- Whatever the value of the variables, it will be assigned to the attributes :
- The first argument passed to useEffect is a function called effect and the second argument is an array of dependencies , When we use this hook , the change of the text button color causes the change of the h1 color :
- The useReducer hook is used for complex state manipulations and state transitions,useReducer is a React hook function that accepts a reducer function, and an initial state :
- useReducer args :
- Calling variables and dispatch :
- It allows to share data between components, but not only between parents and children, we create the context :
- retrieve the values with useContext :
- Providers: defining the value of context :