Frontend Bootcamp 2021
Carlos Contreras
me
Class
React 16.8. was released
Functions that add state variables to functional components and instrument the lifecycle methods of classes. They tend to start with use
Don't call hooks inside loops, conditions or nested functions.
Don't call hooks from regular JS functions. Instead you can:
useState lets us keep local state in a function component.
The useEffect Hook lets you perform side effects in function components:
If you’re familiar with React class lifecycle methods, you can think of useEffect Hook as componentDidMount, componentDidUpdate, and componentWillUnmount combined.
useContext hook makes it easy to pass data throughout a component tree without manually passing props to every children.
It makes up part of React’s Context API
useReducer works similar to the useState hook, it allows state management in funcional components.
useReducer is usually preferable to useState when you have complex state logic that involves multiple sub-values or when the next state depends on the previous one.
Returns a memoized value.
Returns a memoized callback.
useRef allows us to create a ref object whose .current property is initialized with whatever we pass in as argument.
There are two main uses of useRef:
useImperativeHandle allows you to pass values and functions from a Child component back up to a Parent using a ref . From there, the Parent can either use it itself or pass it to another Child.
useLayoutEffect is identical to useEffect, but its major key difference is that it gets triggered synchronously after rendering the component but before painting to the screen
A custom hook allows you to extract some components logic into a reusable function.
A custom hook is a Javascript function that starts with use and that call can other hooks.
useDebugValue can be used to display a label for custom hooks in React DevTools.