Start a project
npx create-react-app .
Vscode : rfc = react function components
=============================
import React from 'react'
export default function $name() {
return (
<div>
</div>
)
}
jsx
const element = (
<h1 className="greeting">
Hello, world!
</h1>
);
Rendering an Element into the DOM
const element = <h1>Hello, world</h1>;
ReactDOM.render(element, document.getElementById('root'));
Components and Props
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
State and Lifecycle
Random uuid
npm i uuid
import uuidv4 from 'uuid/v4'
return [...prevTodos, {
id: uuidv4(),
name: name,
complete: false
}]
Build
npm run build