Similarly to the Login component, we can also use the useDispatch Hook in the Register component, as shown in the following steps:
- Edit src/user/Register.js and import the useDispatch Hook:
import { useDispatch } from '../hooks'
- Then, replace the current Context Hook with our custom Dispatch Hook, as shown here:
const dispatch = useDispatch()
Now the Register component also makes use of our custom Hook instead of directly accessing the dispatch function.