Which Hook can we use to simplify input field handling?
We can use the useInput Hook from the react-hookedup library
How are thecomponentDidMountandcomponentWillUnmountlife cycles implemented using Effect Hooks?
componentDidMount can be implemented by using an Effect Hook with an empty array passed as the second argument. For example, useEffect(() => console.log('did mount'), []).
componentWillUnmount can be implemented by returning a function from an Effect Hook with an empty array passed as the second argument, for example, useEffect(() => { return () => console.log('will unmount') }, []).
How can we use Hooks to get the behavior ofthis.setState()?
this.setState() merges the existing state object with the given state object. We can get the same behavior by using the useMergeState Hook instead of a simple State Hook.
Why should we use timer Hooks instead of callingsetTimeoutandsetIntervaldirectly?
When defining simple timeouts or intervals they are going to reset when the component re-renders. To prevent this resetting from happening, we have to use the useTimeout and useInterval Hooks from react-hookedup instead.
Which Hooks can we use to simplify dealing with common data structures?
We can use the useBoolean, useArray, and useCounter Hooks from react-hookedup
When should we use responsive design with Hooks versus simply using CSS media queries?
We should use Hooks for responsive design when rendering elements within a canvas or WebGL, or when we dynamically want to decide whether to load components based on the window size
Which Hook can we use to implement undo/redo functionality?
We can use the useUndo Hook from the use-undo library to implement simple undo/redo functionality in our app
What is debouncing? Why do we need to do it?
Debouncing means that a function will only be called after a certain amount of time, not every time an event triggers it. Using debouncing, we can store a value entered in a text field in the undo history only after each second, not after every typed character.
Which Hook can we use for debouncing?
We can use the useDebounce or the useDebouncedCallback Hook from the use-debounce library