Skip to content

Instantly share code, notes, and snippets.

@ross-u
Last active February 17, 2022 03:36
Show Gist options
  • Save ross-u/1bdf19c008db2c7acff6007cbb223d57 to your computer and use it in GitHub Desktop.
Save ross-u/1bdf19c008db2c7acff6007cbb223d57 to your computer and use it in GitHub Desktop.
React | class vs function components & state

React | state


1. What is the difference between the React's function components and class components ?


Function components

Function components have _____ object which contains values passed to the component via props/attributes, and they don't have render or lifecycle methods.

This is the reason why they are called "functional stateless components".

Function component _____ (returns or renders ?? ) a JSX string.


Class components

Class components have _____ and props.

Class components have a _______ method which renders the JSX.


2. What is the component state ?

The state is an _____ defined inside of the React class component.

React class components have React's built-in method _____ that we must use to update the state.

React's built-in setState() method triggers _______________________ when state is changed.

Only the class component itself can define the _______ or change it's existing _______ through this.setState().


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment