Let's refactor some class components using hooks! You'll recognize this code from a portion of the react router lab.
Refactor DogRandom
so that:
- It is a functional component
- It uses
useState
to setup component state - It uses
useEffect
in place ofcomponentDidMount
. This effect should only run once when the component mounts.
Refactor DogRandomNum
so that:
- It is a functional component
- It uses
useState
to setup component state - It uses
useEffect
in place ofcomponentDidMount
. This effect should only run once when the component mounts. - It uses the
useParams
hook from the react router library (instead ofprops.match.params
) to grab information about the current route.