Source: 1.Freecodecamp https://learn.freecodecamp.org/front-end-libraries/react 2.Scrimba https://scrimba.com/g/glearnreact 3.
Created
January 21, 2019 07:03
-
-
Save KimTrijnh/fda47470b81b216526811cf44475a12d to your computer and use it in GitHub Desktop.
React & Redux
React project
recipe box
- thiết lập môi trường với
npx create-react-app recipe box
Create React App is a comfortable environment for learning React, and is the best way to start building a new single-page application in React.
https://reactjs.org/docs/create-a-new-react-app.html
SCRIMBA
class syntax to create a component
import React from "react"
// function App(props) {
// return (
// <div>
// <h1>{props.whatever}</h1>
// </div>
// )
// }
class App extends React.Component {
yourMethodHere() {
}
render() {
return (
<div>
<h1>{this.props.whatever}</h1>
</div>
)
}
}
export default App
```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Intro REACT
open-source JavaScript library for building user interfaces (UI)
create components, handle state and props, utilize event listeners and certain life cycle methods to update data as it changes.
React combines HTML with JavaScript functionality to create its own markup language, JSX
Virtual DOM
ReactDOM.render(JSX, document.getElementById('root')).
This function call is what places your JSX into React's own lightweight representation of the DOM.
React then uses snapshots of its own DOM to optimize updating only specific parts of the actual DOM.
1. JSX JAVASCRIP EXTENSION
-allows you to write HTML directly within JavaScript
class in HTML > className in JSX (class is a reserved words in JS)
JSX use camelCase.
Any JSX element can be written with a self-closing tag, and every element must be closed.
Render HTML Elements to the DOM
Create components
There are two ways to create a React component.
can use to nest inside
lúc này các properties của component này sẽ được lưu trong 1 object có tên props
=> props = {user: 'Mark}
sử dụng props trong JSX , treated as JS cod=> eg.
my name is {props.user}
Tạo default prop
ComponentName.defaultProps = { property : 'value'}