├── LICENSE
└── README.md
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Walmyr
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Epic React
2 |
3 | ## React Fundamentals
4 |
5 | ### _Exercise 1 - Hello World using vanilla JavaScript_
6 |
7 | It's essential to understand how to manipulate DOM nodes with pure JavaScript before jumping into React.
8 |
9 | This exercise let us practice DOM manipulations such as element's creation, setting different kinds of attributes into elements, such as `id`, `textContent`, and `className`, and append elements to the DOM. This means that even with an "empty" HTML, with can still "tell" the browser what to render and make interactive web pages.
10 |
11 | ### _Exercise 2 - Hello World using React and `ReactDOM` APIs_
12 |
13 | As it is crucial to understand how to manipulate the DOM through its JavaScript API, this also applies to understand React's APIs before jumping into JSX.
14 |
15 | While we use React to create elements, `ReactDOM` is used to render those elements into the DOM. They are separate things on purpose, and there are libraries such as `ReactNative`, which renders things on native apps instead of web browsers.
16 |
17 | The property children used when creating a React component can accept a simple string, which defines the content of that element, or an array of sub-elements.
18 |
19 | When it's time to grab the parent element to render our components into the DOM, we still use pure JavaScript to query the 'root' element `(document.getElementById('root')`).
20 |
21 | For exercise purposes, it's ok to add React into a `script` tag. When running software in production, other approaches are recommended.
22 |
23 | Components are reusable pieces of code that can compose web applications.
24 |
25 | ### _Exercise 3 - JSX and Babel_
26 | JSX is a JS syntax sugar that allows us to create React components in a cleaner and more imperative way. JSX is powered by Babel, which transpile the code that the browser cannot understand into JavaScript code (e.g., `` into `React.createElement('div')`).
27 |
28 | We also import Babel inside of a script tag only for exercise purposes.
29 |
30 | Babel's transpilation allows us to spread `props` into React components. It enables using any modern JavaScript logic (ES6+), such as template literals, shorthand property names, object, or array destructuring, etc.
31 |
32 | To use Babel imported from a `script` tag, we use `