Saturday, August 27, 2022

Key React features and concepts

props - parameters in functional component.

children of props are <div>here</div>.

State - a built-in React object that is used to contain data or information about the component. A component's state can change over time; whenever it changes, the component re-renders.

State in App (parent component) passes this.state to other (child) components on page.

State storage.

Components lifecycle - https://reactjs.org/docs/state-and-lifecycle.html

1 component - 1 function => ideally.

Functional component gets props and just render HTML. If internal state or lifecycle are not necessary, functions are way to go.

Put context for all methods into constructor. // this.change = this.change.bind(this) or use arrow function because it automatically get lexical scoping.

{} // everything in curly brackets is JavaScript expression

Unique keys are needed to update certain component ONLY and not rerender whole page.

APIs for getting information.

 const { users, searchField } = this.state; // destructuring state and making const variables out it's data

No comments:

Post a Comment