You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow the walkthrough to learn how to submit your homework for each week:
10
+
11
+
ONE TIME ONLY (START OF EVERY MODULE)
12
+
13
+
1. Create a [fork](https://help.github.com/en/articles/fork-a-repo) of the teacher's forked repository (ask in Slack what the URL for it is). You do this by using the `fork` option on the top right
14
+
2. Navigate to the URL of the cloned repository (it should be in your personal GitHub account, under "repositories")
15
+
3. Clone the repository, using SSH, to your local machine. You can do this by typing in `git clone <git url>` in the command line
16
+
4. On your local machine, navigate to the folder using the command line
17
+
5. Make sure you've cloned it correctly by running `git status` from the command line.
18
+
19
+
EVERY WEEK
20
+
21
+
1. Create a new branch for each week you have homework. For example, for the week 1 homework for React create a branch called `week-1-homework-YOUR_NAME`
22
+
2. Inside the correct week folder, create another folder called `homework`. Make your homework files in there, while on the correct branch
23
+
3. Once you're finished, add and commit everything. Make the commit message meaningful, for example `finished project for homework week1`
24
+
4. Push the branch to your forked repository
25
+
5. On the GitHub page of your forked repository, click on the `create pull request` button. Make sure the `base repository` is your teacher's repository, on branch master
26
+
6. Give the pull request a title in the following format:
27
+
28
+
```markdown
29
+
Homework week 1 <Your name>
30
+
```
31
+
32
+
7. Submit the pull request from your forked repository branch into the `master` branch
33
+
8. Do a little victory dance because you did it! Good job!
34
+
35
+
For a visual walkthrough the steps please watch the following video one of our teachers, Unmesh Joshi, has made:
Copy file name to clipboardexpand all lines: week1/README.md
+7-3
Original file line number
Diff line number
Diff line change
@@ -196,7 +196,11 @@ In our example, it means that our `props` can only move from `<Contact>` > `<Add
196
196
197
197
A static website is a collection of HTML, CSS and client-side JavaScript files. That's it. It is usually only a frontend, hosted on a web server that only serves the pages the client asks for (for example, `/`, `/about` or `/privacy`).
198
198
199
-
As you've learned in the Node.js module, we can use server-side frameworks like `Express` or just native Node.js modules (like `http`)
199
+
As you've learned in the Node.js module, we can use server-side frameworks like `Express` or just native Node.js modules (like `http`) in order to serve our static files to a client.
200
+
201
+
But what if we don't want to setup a whole web server to do this?
202
+
203
+
### Static site generators
200
204
201
205
We call these `static site generators`. They take a lot of the basic web server setup out of our hands. All we have to do is upload our frontend (in other words, our static website) to that particular service's web server and that's it. The generator creates a URL for us that we can use to access our website.
202
206
@@ -211,6 +215,6 @@ To learn more about static site generators, study the following:
211
215
-[The Reign of Static Site Generators](https://www.netlify.com/blog/2018/07/12/the-reign-of-static-site-generators/)
212
216
-[Why use a Static Site Generator](https://www.youtube.com/watch?v=mDKQGANttyE)
Copy file name to clipboardexpand all lines: week2/MAKEME.md
+25-10
Original file line number
Diff line number
Diff line change
@@ -15,21 +15,22 @@ We'll start the week off with some online exercises again. Complete the exercise
15
15
16
16
## **2. React exercises**
17
17
18
-
> Inside of your `React` fork, go to the `week1` folder and create a React application called `react-exercises` (use `create-react-app`). Inside of the `src` folder create a JavaScript file with an appropriate name.
18
+
> Inside of your `React` fork, go to the `week2` folder and create a React application called `react-exercises` (use `create-react-app`). Inside of the `src` folder create a JavaScript file with an appropriate name.
19
19
20
20
**Exercise 1: New friend on demand**
21
21
22
22
What if there was an app that could generate a new friend, instantly? How about we make one!
23
23
24
24
In this exercise we'll be using the following API endpoint: `https://www.randomuser.me/api?results=1`
25
25
26
-
1. Create 2 functional components called `<Friend>` and `<Button>`
27
-
2. Inside create a state variable called `friend` (with initial state of `{}`) and state handler `setFriend`
28
-
3. Inside (before the return statement) also create a function called `getFriend`. The purpose of this function is to make an API call to `https://www.randomuser.me/api?results=1`. You can either use `fetch` or `axios`. At the end of the function reassign the `friend` state value using `setFriend`
26
+
1. Create 3 functional components called `<Friend>`, `<FriendProfile>` and `<Button>`
27
+
2. Inside `<Friend>`create a state variable called `friend` (with an initial state of `{}`) and state handler `setFriend`
28
+
3. Inside `<Friend>`(before the return statement) also create a function called `getFriend`. The purpose of this function is to make an API call to `https://www.randomuser.me/api?results=1`. You can either use `fetch` or `axios`. At the end of the function reassign the `friend` state variable using `setFriend`
29
29
4. Inside the `<Button>` component, create a `<button>` that has the text "Get a friend!" and `onClick` attribute
30
30
5. Pass down the function `getFriend` to `<Button>`
31
-
6. NOT FINISHED
32
-
7. Test if everything works by importing it into the top level component, which is `<App>`
31
+
6. Inside `<FriendProfile>` create an `<ul>` that showcases the following attributes of the person: The first and last names, the address and country, the email address, and finally also the phone number
32
+
7. Pass down the `friend` state variable to the `<FriendProfile>`
33
+
8. Test if everything works by importing it into the top level component, which is `<App>`
33
34
34
35
**Exercise 2: Dog photo gallery**
35
36
@@ -39,13 +40,25 @@ In this exercise we'll be using the following API endpoint: `https://dog.ceo/api
39
40
40
41
1. Create 3 functional components: `<DogGallery>`, `<DogPhoto>` and `<Button>`
41
42
2. Inside `<DogGallery>` create a state variable called `dogPhotos` (initialize with value `[]`) and state handler `setDogPhotos`
42
-
3. Inside (before the return statement) also create a function called `getDogPhoto`. The purpose of this function is to make an API call to `https://dog.ceo/api/breeds/image/random`. You can either use `fetch` or `axios`. At the end of the function push the new `dog image URL` into the `dogPhotos` array state value using `setDogPhotos`
43
+
3. Inside (before the return statement) also create a function called `getDogPhoto`. The purpose of this function is to make an API call to `https://dog.ceo/api/breeds/image/random`. You can either use `fetch` or `axios`. At the end of the function push the new `dog image URL` into the `dogPhotos` array state variable using `setDogPhotos`
43
44
4. Inside the `<Button>` component, create a `<button>` that has the text "Get a dog!" and `onClick` attribute
44
45
5. Pass down the function `getDogPhoto` to `<Button>`
45
-
6. Inside `<DogGallery>` return all the dogs stored in the `dogPhotos` array using the `map()` function. However, when there are no dogs yet make sure to display the message "Get your first dog by clicking the button!"
46
-
7. Test your components by importing it into the top level
46
+
6. Inside `<DogGallery>` return all the dogs stored in the `dogPhotos` array using the `map()` function. Pass down each `dogPhoto` into an instance of `<DogPhoto>`.
47
+
7. However, when there are no dogs in the array yet make sure to display the message "Get your first dog by clicking the button!"
48
+
8. Test your components by importing it into the top level component, which is `<App>`
47
49
48
-
**Exercise 3**
50
+
**Exercise 3: Random Joke Generator**
51
+
52
+
Never run out of jokes with the Random Joke Generator!
53
+
54
+
In this exercise we'll be using the following API endpoint: `https://official-joke-api.appspot.com/random_joke`
55
+
56
+
1. Create 2 functional components: `<RandomJoke>` and `<Joke>`
57
+
2. Inside `<RandomJoke>` create a state variable called `joke` (with initial state `{}`) and state handler `setJoke`
58
+
3. Make use of the `useEffect` hook to make an asynchronous API call to the API endpoint. Put the end result into the state variable using `setJoke`
59
+
4. Now pass the reassigned state variable `joke` to the `<Joke>` component
60
+
5. Inside the `<Joke>` component, display the `setup` and `punchline` attributes in 2 `<p>` tags
61
+
6. Test out your work by importing your components into the top level component, which is `<App>`
49
62
50
63
## **3. Code along**
51
64
@@ -77,6 +90,8 @@ Here are the requirements your project needs to fulfill:
77
90
- Make an API call when the button is clicked
78
91
- Display the city + weather information similar to week 1
79
92
- Make a component for the search
93
+
- Incorporate error handling for the API call
94
+
- Show user feedback when there are no cities searched for yet
Copy file name to clipboardexpand all lines: week2/README.md
+14-1
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ Like any other system, React is always evolving. Before we had Hooks, we used to
23
23
```js
24
24
classExampleextendsReact.Component {
25
25
state = {
26
-
exampleMessage:'This message is for the example'
26
+
exampleMessage:"This message is for the example"
27
27
};
28
28
29
29
render() {
@@ -108,4 +108,17 @@ Forms have always been slightly different than any other element in HTML. So it
108
108
109
109
### Controlled vs. uncontrolled
110
110
111
+
These terms refer to whether or not a component has its own state or not. We're talking about a `controlled` component when it doesn't have its own state: it's being controlled by
112
+
113
+
A component is `uncontrolled` when it does have state, meaning state values are defined within in.
114
+
115
+
Learn more about this here:
116
+
117
+
-[Controlled and uncontrolled elements](https://www.youtube.com/watch?v=nSGZEQa5C_c)
118
+
-[How React Hooks change the way we build forms](https://www.youtube.com/watch?v=8yo44xN7-nQ)
119
+
111
120
### EventListeners & preventing default behavior
121
+
122
+
## Finished?
123
+
124
+
Are you finished with going through the materials? High five! If you feel ready to get practical, click [here](./MAKEME.md).
Copy file name to clipboardexpand all lines: week3/MAKEME.md
+21-11
Original file line number
Diff line number
Diff line change
@@ -15,13 +15,7 @@ This week we'll practice some (hopefully) familiar concepts, with some online ex
15
15
16
16
## **2. React exercises**
17
17
18
-
> Inside of your `React` fork, go to the `week3` folder and create a folder called `react-exercises`. For each exercise create a new folder (call it `exercise` follwed by the right number) and create 3 files: and `index.html`, `script.js` and `style.css`.
19
-
20
-
**Exercise 1**
21
-
22
-
**Exercise 2**
23
-
24
-
**Exercise 3**
18
+
**No exercises this week**
25
19
26
20
## **3. Code along**
27
21
@@ -31,9 +25,26 @@ In the following tutorial you'll learn how to make
31
25
32
26
## **4. PROJECT: Hack Your Weather III**
33
27
34
-
> Every week ends with a project you have to build on your own. Instead of getting clear-cut instructions, you'll get a list of criteria that your project needs to measure up to.
28
+
> Make sure you're building on last week's codebase.
29
+
30
+
The main additions you'll add this week is to (1) keep adding to the list of already searched cities and (2) allow users to remove a city from previous search result.
31
+
32
+
### 1. Requirements
33
+
34
+
By the end of this week's assignment your application should look similar to this:
35
+
36
+

37
+
38
+
Here are the requirements your project needs to fulfill:
39
+
40
+
- Any time a user searches for a new city, add it to a list of already searched cities
41
+
- Allow a user to delete a search entry, by clicking the "X"
42
+
- Only allow a user to use the "Search City" button when the input field has at least 1 character
43
+
44
+
Hints:
35
45
36
-
> Before you start, create a new folder called `project` that includes the files for the following app you'll be building.
46
+
- Think about what data structure makes most sense to use
47
+
- Make use of `filter()` when removing cities
37
48
38
49
## **SUBMIT YOUR HOMEWORK!**
39
50
@@ -43,7 +54,6 @@ If you need a refresher, take a look at the following [guide](../hand-in-homewor
43
54
44
55
The homework that needs to be submitted is the following:
Copy file name to clipboardexpand all lines: week3/README.md
+68-4
Original file line number
Diff line number
Diff line change
@@ -6,14 +6,78 @@ These are the topics for week 3:
6
6
7
7
1. Hooks II
8
8
- Building custom hooks
9
-
2. Third party components
9
+
- Using other people's custom hooks
10
+
2. Third party React tools
11
+
- UI toolkits
12
+
- Utilities
10
13
11
14
## 1. Hooks II
12
15
13
16
### Building custom hooks
14
17
15
-
## 2. Third party components
18
+
One of the main benefits of using the React hooks (like `useState`, `useEffect`, etc.), is that they can be used in any functional component.
16
19
17
-
Why write everything yourself when you can access other's software, for free? Like with any software ecosystem, whether it's React, Angular or Vue, there will be developers who've made certain functionalities easier for you to
20
+
However, that's not the only big benefit. Another one is that it allows us to isolate `stateful logic` into a reusable function that can be used in other functional components.
18
21
19
-
It's highly recommended
22
+
This `stateful logic` is just a complicated way for saying state variables and the instructions that manipulate it.
23
+
24
+
In a custom hook we can create state everytime we use it, and modify it according to the instructions that are included in the hook. This is the strength of using custom hooks: by defining custom hooks we can replicate a certain functionality for us to use in multiple different functional components.
25
+
26
+
In terms of implementation, a custom Hook is simply a JavaScript function whose name starts with ”use” (for example, `useSomeAction`). It incorporates existing hooks (like `useState`) and adds logic to it.
27
+
28
+
Study the following to learn more about it:
29
+
30
+
-[Building your own hooks](https://reactjs.org/docs/hooks-custom.html)
Like anything in development, once someone has found a solution to a common problem it (hopefully) gets published for everyone to use. This is also the case with `hooks`.
36
+
37
+
Check the following resources out to learn more about these custom hooks others have made for you to use:
38
+
39
+
-[usehooks.com](https://usehooks.com/)
40
+
41
+
## 2. Third party React tools
42
+
43
+
Third party React tools can roughly be divided into 2 categories:
44
+
45
+
1. UI toolkits
46
+
2. Utilities
47
+
48
+
### UI toolkits
49
+
50
+
These kind of component libraries serve to **structure your user interface**. If you've ever worked with a CSS framework, this is what it means.
51
+
52
+
Popular presentational component libraries are the following:
There are also tools that solve certain problems within the React ecosystem.
74
+
75
+
-[Enzyme](https://github.com/airbnb/enzyme) is a React-specific component testing tool, that makes it easier to test your React Components' output
76
+
-[Redux](https://redux.js.org/introduction/getting-started) is a state management tool, used to make it possible to connect every component directly to the entire state and thus eliminates the need to use props or callbacks.
77
+
-[React Intl](https://github.com/formatjs/react-intl) is a tool that provides an application the ability to have multiple languages (English, Dutch, etc.) within the application
78
+
79
+
All of these tools are not necessarily React-specific, but allow us to use React in order to create more engaging, feature-rich applications.
80
+
81
+
## Finished?
82
+
83
+
Are you finished with going through the materials? High five! If you feel ready to get practical, click [here](./MAKEME.md).
Copy file name to clipboardexpand all lines: week4/MAKEME.md
+34-11
Original file line number
Diff line number
Diff line change
@@ -15,13 +15,7 @@ Let's finish the online exercises. Start from `Review Using Props with Stateless
15
15
16
16
## **2. React exercises**
17
17
18
-
> Inside of your `React` fork, go to the `week4` folder and create a folder called `react-exercises`. For each exercise create a new folder (call it `exercise` follwed by the right number) and create 3 files: and `index.html`, `script.js` and `style.css`.
19
-
20
-
**Exercise 1**
21
-
22
-
**Exercise 2**
23
-
24
-
**Exercise 3**
18
+
**No exercises this week**
25
19
26
20
## **3. Code along**
27
21
@@ -31,9 +25,39 @@ In the following tutorial you'll learn how to
31
25
32
26
## **4. PROJECT: Hack Your Weather IV**
33
27
34
-
> Every week ends with a project you have to build on your own. Instead of getting clear-cut instructions, you'll get a list of criteria that your project needs to measure up to.
28
+
> Make sure you're building on last week's codebase.
29
+
30
+
This week we'll finish our application by integrating 2 things: `client-side routing` with [React-Router-Dom](https://reacttraining.com/react-router/web/guides/quick-start) and `charting` our data (in either hourly or five day forecasts).
31
+
32
+
### 1. Setup
33
+
34
+
1. Install the following packages: [React Router Dom](https://www.npmjs.com/package/react-router-dom) and [Recharts](https://www.npmjs.com/package/recharts)
35
+
36
+
```
37
+
npm install react-router-dom recharts
38
+
```
39
+
40
+
### 2. Requirements
41
+
42
+
At the end of the week the user interface of your application will look mostly the same, but with an additional page:
43
+
44
+

45
+
46
+
Here are the requirements your project needs to fulfill:
47
+
48
+
- Divide your page into 2 different routes (`/` and `/:cityId`), using `react-router-dom`
49
+
- Allow users to click on the searched city to open the city page
50
+
- The city page will be on a different route identified by the city id (make use of the `<Link>` component given by `react-router-dom`)
51
+
- On the city page there will be several things:
52
+
- Two tabs, one for the hourly forecast and the other for a 5 day forecast
53
+
- A chart (made with `recharts`) that displays the correct data according to which tab is active
54
+
- Clicking on a tab will do 2 things: (1) make an API call to get the right data (using the city id from the URL params), and (2) switch the active component (from the hourly forecast to the five day forecast and vice versa)
55
+
- Add a "Back" button to go back to `/`, on the city page
56
+
57
+
Hints:
35
58
36
-
> Before you start, create a new folder called `project` that includes the files for the following app you'll be building.
59
+
- Read the documentation to get a basic sense of what problems both `react-router-dom` and `recharts` are trying to solve, and to learn how to use them
60
+
- Make sure to have a clear overview of your application so far, before you add this week's features to it
37
61
38
62
## **SUBMIT YOUR HOMEWORK!**
39
63
@@ -43,7 +67,6 @@ If you need a refresher, take a look at the following [guide](../hand-in-homewor
43
67
44
68
The homework that needs to be submitted is the following:
0 commit comments