By doing this homework you will learn:
- How to use
create-react-appto create new React applications easily - Better project folder organisation
- Make
API callsusingcomponentDidMount() - Connect a React frontend with a Node.js backend
NOTE: If you already use
create-react-appyou can skip step 1!
- Create a new React application using
create-react-app(CRA)
In order to make use of CRA, you need to install it to your machine through the CLI using NPM.
- Inside your CLI, type in
npm install -g create-react-app. Verify that it's installed by typingcreate-react-appin the CLI. - Create a new project folder called
react-hyfinside the forked React project folder - Create a new React application using CRA and call it
react-hyf-clientInsidereact-hyf-client: - Manually move the code from your old homeworks into a new
<PreviousHomeworks />component. Divide it up into smaller components if needed. - Add the
<PreviousHomeworks />component inside the<App />component
- Make an API call to the following URL: https://uinames.com/api/?amount=10
- Make use of
componentDidMount() - Put the returned JSON in state
- Create reusable components, at least 3
- Present the returned data inside a container component called
<HomeworkWeek3 /> - Write as little (repeated) code as possible (tip: make use of the
map()function)
- Connect your CRA with a Express-based Node.js backend (Development server)
- Inside the root folder,
react-hyf, create a new folder calledserver - Initialize NPM and create a
package.jsonfile with the following packages:express,nodemonandconcurrently - Inside the
serverfolder, create aserver.js. This file will hold the code that creates your Express server - Write your basic Express server code, which should include: (1) loading in of Express and initializing it, (2) code that let's Express know where you hold your static files, (3) a GET route that sends the
index.htmlfile from yourpublicfolder in the client as a response to the browser (take the/route), (4) a listener to a random PORT number (for example,1234), (5) inside thepackage.jsonof write a rule for a proxy that refers the React development server to the Express server port
- Project: Meme Generator App
- Project: Simple Weather App
You will be scored on:
- Correct functionality
- Code organisation
- Cleanliness of code
When you are done issue a PR with your homework as explained in this video made by Daan.