state is an obj (state={}
)
setState() - updates the state
How to use lifecycle methods
render() - convert what is inside return()
into HTML
componentDidMount() - after the first render, only runs once
componentDidUpdate() - after setState()
How to write components in React
class nameOfComponent extends React.Component {}
function nameOfComponent {}
const nameOfComponent = () => {}
Syntax for importing a component
import <NameOfComponent> from "path"
import Button from "./Button"
We use components to avoid repeating ourselves because we can simply write some code once and reuse it whenever we need to by importing
Passing props to child components
Syntax for passing props
<Component nameOfProp={valueOfProp}/>
<Button text={"my message for my button child"}/>
<Homepage users={[
{id:1, username: 'blake'},
{id:2, username: 'RYAN'},
]}/>
We want our child components to receive some data (props)
Remember to open your console to see if there are any error messages