To support my React First Steps course on O'Reilly Learning Portal
I'd love to connect with you to provide any help I can with learning React. Please reach out.
We've created solutions at certain checkpoints.
- cd to the folder of your choice
- npm install
- npm run start
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.
This one is simple. Just run create-react-app to create the application.
- Make three component files: PeopleQuery.js, PeopleList.js and Person.js.
- Add the data-reading code to App.js. If you like, you can copy the fetcher from assets/fetchPeople.js.
- Add JSX to App.js to host PeopleQuery.js and PeopleList.js.
- Add JSX to PeopleList.js to host Person.js.
- Add a button to App.js to fetch 10 people. Console.log() them.
- Add a people.map() to display all 10 of their names in App.js.
Now, drawing the people in App.js doesn't seem clean. We should be drawing the people in PeopleList.js. But we have to get those people into PeopleList somehow. Props will do the trick!
- Pass people from App.js down to PeopleList.js
- Pass setPeople down to PeopleQuery.js and run the fetch from there.
- Add in a CSS library like material-design-lite.
- Use JavaScript styles for the flexbox layout, and for sizing the person photo.
- Create searchParams as a state variable; nationality, gender, and number of results.
- Call the setSearchParams on each of the changes to nationality, gender, and number of results.
- Pass those values into the fetch function