React useEffect and Data Fetching

Learning Goals

  • Learn what a side effect is

  • Learn the syntax for the useEffect hook

  • Incorporate useEffect for a primary GET request to fill state

  • Learn how to use the useEffect dependency array to control when it triggers

  • Learn how to make a post request to add additional data

  • BONUS: Learn how to do full CRUD with an array in state

Tools

Begin with npm install and npm start

In a seperate terminal tab you can run the json-server with npm run server. This works because we added a new script called server in our `package.json'.

Your endpoints are http://localhost:3002/raccoons and http://localhost:3002/comics.