To support my Hands On React course on O'Reilly Learning Portal
I'd love to connect with you to provide help learning React. Please reach out.
We've created solutions at certain checkpoints.
- cd to the folder of your choice
- npm install
- npm run dev
Of course you can make any changes to the code you like at this point. Just save a file and the app will refresh in your browser.
(No exercise for section 1 - Intro to React).
This one is simple. Just npm create vite
to create the application.
- Make two component files: People.jsx and Person.jsx.
- Add the data-reading code to People.jsx. If you like, you can copy the fetcher from assets/fetchPeople.js.
Now, drawing the people in App.js doesn't seem clean. We should be drawing the people in People.js. But we have to get those people into PeopleList somehow. Props will do the trick! 3. Add JSX to App.jsx to host People.js. 4. Add JSX to People.js to host Person.js. 5. Add a button to People.js to fetch 10 people. Console.log() them.
- Make the delete button call your new deletePerson function
- Add in CSS to format the Person. Put this in Person.css and import it.
- Use JavaScript styles for the flexbox layout.
- In People, add a function to delete a single person from the people list. Make it call setState() with the new list of people.
- Add a delete button to each Person.
- Pass the function from People into Person via a prop.
- Make the delete button call your new deletePerson function
Now, drawing the people in App.js doesn't seem clean. We should be drawing the people in People.js. But we have to get those people into PeopleList somehow. Props will do the trick!
- Pass people from People.js down to Person.js