October 2019
Intermediate to advanced
426 pages
11h 49m
English
First of all, we are going to extract the Effect Hook from our Login component to a separate useRegisterEffect Hook function. This function will accept the following values from other Hooks as arguments: user and dispatch.
Let's create a local Effect Hook for the Register component now using the following steps:
function useRegisterEffect (user, dispatch) {
useEffect(() => { if (user && user.data) { dispatch({ type: 'REGISTER', username: user.data.username }) } }, [dispatch, ...Read now
Unlock full access