Install npm and yarn
node = JS on the server
yarn = dependencies manager
just like composer for PHP Install yarn globally
Install web server
Install live-server globally
yarn global add live-server
npm i live-server -g
Compile React JSX with Babel
Create a HTML file
Add React JS
React use JSX = Javascript Syntax Extension / Javascript XML
SCSS / Less = language extension for CSS
However, browser can’t render JSX...
You have to install Babel, a JS compiler for older browser (ES6, ES7 convert to ES5) It makes JS compatible with older browser, and compile JSX into JS About Babel
Read more at
Babel will generate this code from JSX, that is able to run in the browser...
Install Babel & Babel React Preset
Setup a script
To auto compile src/app.js to public/scripts/app.js for HTML files to use
the src will write JSX codes the public will be auto compiled
Basic JSX
Basic Rules
Every line of JSX only contain 1 container DIV.
Pretty mix of HTML and JSX
Javascript Expression
Mixing variables into JSX
you can mix var, function with return values you can mix another JSX expression put other JSX in other vars Short Syntax Conditioning Rendering
Events & Attributes
Notes for ID, ClassName
When we target and bind events to buttons or divs, we often use ID or class. But Some HTML do not work the same in JSX.
class should change to className because class is reserved for Class Object all 2-word attributes should have 2 camelCase but refer to the list for correct syntax in JSX
Manual Re-render
JSX does not re-render everytimes data has changed
you have to manually re-render put ReactDOM.render() inside a function and call it everytimes data has changed
Forms & Input
Reference Event List
Array in JSX
When JSX see an array, it breaks and shows all.
null, undefined, false will not be displayed MUST set unique for each array elements
Small Apps
Picking a random Option
Visibility Toggle
React Dev Tools
Install React Dev Tool extension