Skip to content

Commit 70eb817

Browse files
committed
react library (feat): added explanation of react in a simple html file
1 parent 7f765c7 commit 70eb817

File tree

4 files changed

+49
-12
lines changed

4 files changed

+49
-12
lines changed

docs/_sidebar.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Contents
1212

1313
- [Overview](contents/overview.md)
14+
- [Understanding the React magic](contents/react_library.md)
1415
- [Create your portfolio website with CRA](contents/create_react_app.md)
1516
- Basic Topics
1617

docs/contents/create_react_app.md

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Create-React-App
22

3-
The [create-react-app](https://github.com/facebook/create-react-app) allows you to build a React website with just one line of code.
3+
Setting up a react app can be overwhelming when doing it the first time. There's tons of setup to do before actually coding in React. The good thing about the maintainers of React, **Facebook**, is that they developed a boilerplate app that can get us to start with React without the painful setup.
4+
5+
>The [create-react-app](https://github.com/facebook/create-react-app) allows you to build a React website with just one line of code.
46
57
## Build your portfolio with create-react-app
68

@@ -43,22 +45,22 @@ We now have our React website! Run it on your localhost:
4345
![React Default Page](../_media/react_default_page.gif)
4446

4547
## What does each generated file do?
46-
| File | Description |
47-
| ------------ | ------------------------------------------- |
48-
| node_modules | where dependencies are installed |
49-
| package.json | where dependencies and scripts are declared |
50-
| public | where the `index.html` is placed |
51-
| src | where the development files are |
48+
| File | Description |
49+
| ------------ | -------------------------------------------------------------------- |
50+
| node_modules | where dependencies are installed |
51+
| package.json | where dependencies and scripts are declared |
52+
| public | where the `index.html` is placed |
53+
| src | where the development files are, contains the components of your app |
5254

5355
## Going through the flow of the project files
5456
The browser starts with the index.html file and reads the root div. The root div is the starting component. All component are rendered within the root div.
5557

56-
`index.html` at about line 30
58+
`public/index.html` at about line 30
5759
```html
5860
<div id="root"></div>
5961
```
6062

61-
`index.js` at about line 7 states that the component **_App_** should be rendered within the root component.
63+
`src/index.js` at about line 7 states that the component **_App_** should be rendered within the root component.
6264
```javascript
6365
ReactDOM.render(<App />, document.getElementById("root"));
6466
```
@@ -93,7 +95,7 @@ ReactDOM.render(<App />, document.getElementById("root"));
9395

9496
export default App
9597
```
96-
Preview your changes in the browser. Run `yarn start`.
98+
Preview your changes in the browser. Run `yarn start`. React reloads the browser when you make edits, you don't have to restart the service everytime.
9799

98100
The browser should display the header, `Hello Women Who Code Manila!`.
99-
Play around the App and Profile components and design the landing page for your portfolio.
101+
> Activity: Play around the App and Profile components and design the landing page for your portfolio.

docs/contents/overview.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ Components imported from another component looks very similar to an HTML tag. In
8282

8383
Now that we know components and jsx, we can start building our first React-powered website. However, building React websites from scratch can be too tedious. It requires a lot of setup. Facebook has developed **_create-react-app_** that allows you to build your React website in just a few minutes.
8484

85-
[Let's start building!](contents/create_react_app.md)
85+
[Understanding the React library](contents/react_library.md)

docs/contents/react_library.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# React is a Javascript library
2+
3+
To fully understand React, let's see how it works in an HTML file. Like many other Javascript libraries, react can be loaded from a script tag.
4+
5+
6+
index.html
7+
```html
8+
<!DOCTYPE html>
9+
<html>
10+
<head>
11+
<meta charset="UTF-8" />
12+
<title>Hello World</title>
13+
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
14+
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
15+
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
16+
</head>
17+
<body>
18+
<div id="myDiv"></div>
19+
<script type="text/babel">
20+
21+
<!-- React Code Goes Here -->
22+
23+
</script>
24+
</body>
25+
</html>
26+
```
27+
In the HTML example above, three react scripts are imported:
28+
1. `react`: the core react library
29+
2. `react-dom`: provides DOM-specific methods that can be used at the top level of your app
30+
3. `babel`: the transpiler
31+
32+
React manipulates the root component, div with the id `myDiv`, depending on what's declared in the `render()` method. The root component "reacts" to the updates or renders thrown to it.
33+
34+
[Let's start building!](contents/create_react_app.md)

0 commit comments

Comments
 (0)