30 Days Of React
Author: Asabeneh Yetayeh
How to Use Repo
|02||Getting Started React|
- How to Use Repo
Congratulations on deciding to participate in 30 days of React programming challenge. In this challenge you will learn everything you need to use to develop a React application. In the end of the challenge you will get a 30DaysOfReact programming challenge completion certificate. In case you need help or if you would like to help others you may join the telegram group.
To get along with the challenge you need to have the following:
- A computer
- A browser
- A code editor
How to Use Repo
Star and Fork this Repo
Star this repo to support this work and Fork the repo to create your own copy to work from.
Clone your Fork
You should always work directly from your forked copy.
# note that an `ssh` link is used here, but an `https` link will work the same git clone [email protected]:username/30-Days-Of-React.git cd 30-Days-Of-React
Create a New Branch
To complete daily exercises, my suggestion is to create a separate branch to house your exercise folder or any other changes you make. This will keep your master branch clean at all times, which means your master will always be similar to the original master.
git checkout -b exercise-solutions # `-b` creates the branch if it does not exist
Structure Exercise Solutions
In your new branch, you can use files/folders to structure your solutions to daily exercises
mkdir -p solutions/day-01 # `-p` helps create nested directories touch solutions/day-01/level1.js # touch creates a file
Commit Excercise Solutions
Commit your solutions to your Fork
git add solutions/day-01/level1.js git commit -m "chore: exercise level1 complete" git push origin exercise-solutions # branch `exercise-solutions` was created earlier
Update your Fork Daily
This repo will be updated daily throughout the month. When a new day's content becomes available, you can update your forked copy with the steps below.
# 1. switch to master branch git checkout master # 2. check if your local copy has a link to original `...Asabeneh/30-Days-Of-React.git` git remote -v # 3. if not, add a link to original, you can choose any name for the link or use `upstream` git remote add upstream [email protected]:Asabeneh/30-Days-Of-React.git # 4. check again to confirm link added git remote -v # 5. now you can fetch updates from original repo, assuming you named this `upstream` git fetch upstream # 6. merge the updates to your local master branch git merge upstream/master master # 7. push the merged updates to your Forked copy on GitHub git push origin master
Note that the updates are only applied to the master branch. If you wish to update any other branch, repeat steps 6-7 with the branch name. See snippet below for
git merge upstream/master exercise-solutions git push origin exercise-solutions
I believe you have the motivation and a strong desire to be a developer, a computer and Internet. In addition to that basic to intermediate level HTML, CSS and JS. If you have those, then you have everything to get started.
You may not need node.js right now but you may need it for later. Install node.js.
After downloading double click and install
We can check if node is installed on our local machine by opening our device terminal or command prompt.
asabeneh $ node -v v12.14.0
When making this tutorial I was using node version 12.14.0, but now the recommended version of node.js for download is 12.17.0.
There are many browsers out there. However, I strongly recommend Google Chrome.
Installing Google Chrome
Opening Google Chrome Console
You can open Google Chrome console either by clicking three dots at the top right corner of the browser, selecting More tools -> Developer tools or using a keyboard shortcut. I prefer using shortcuts.
Mac Command+Option+J Windows/Linux: Ctl+Shift+J
Writing Code on Browser Console
Mac Command+Option+I Windows: Ctl+Shift+I
Console.log with Multiple Arguments
The console.log() function can take multiple parameters separated by comma. The syntax looks like as follows:console.log(param1, param2, param3)
As you can see from the snippet code above, console.log() can take multiple arguments. It is recommended to use as many console.log() prints to check what is happening in your code but don't keep all console.log() tests on your code forever. Make your life easy by keeping the browser console open.
Example: Single Line Comment
// This is the first comment
// This is the second comment
// I am a single line comment
Example: Multiline Comment
/* This is a multiline comment
Multiline comments can take multiple lines
I made a deliberate mistake. As a result, the console raises syntax errors. Actually, the syntax is very informative. It informs what type of mistake was made. By reading the error feedback guideline, we can correct the syntax and fix the problem. The process of identifying and removing errors from a program is called debugging. Let us fix the errors:
console.log('Hello, World!') console.log('Hello, World!')
So far, we saw how to display text using the console.log(). If we are printing text or string using console.log(), the text has to be inside the single quotes, double quotes, or a backtick quotes. Example:
console.log('Hello, World!') console.log('Hello, World!') console.log(`Hello, World!`)
console.log(2 + 3) // Addition console.log(3 - 2) // Subtraction console.log(2 * 3) // Multiplication console.log(3 / 2) // Division console.log(3 % 2) // Modulus - finding remainder console.log(3 ** 2) // Exponentiation 3 ** 2 == 3 * 3
Installing Visual Studio Code
Visual studio code is a very popular open-source text editor. I would recommend to download Visual Studio Code, but if you are in favor of other editors, feel free to follow with what you have.
If you installed Visual Studio Code, let us start using it.
How to Use Visual Studio Code
Open the Visual Studio Code by double-clicking its icon. When you open it, you will get this kind of interface. Try to interact with the labeled icons.