Category: Code

React Lifecycle

constructor One-time setup, assignments.Do not do data-loading inside the constructor, instead do it in componentDidMount. render Return JSX, nothing else! componentDidMount Place for data-loading, api requests etc. componentDidUpdate Place to do more data-loading when state/props change. Render-method will be called just before this method. componentWillUnmount Place for cleanup       Rarely used lifecycle methods: …

Functional Components vs Class Components in React

Old version of React: Functional components – produce JSX to show content Class components – produce JSX to show content, use the lifecycle method system, use the state system New version of React: Functional components can: Express things at a certain time with Hooks instead of the lifecycle method system class components are using. use …

Rest and Spread operators in JS

By placing … before the arrayname as you are passing the array as a argument when calling a function, you can split an array up so the function will see each array value as different arguments. By placing … before an parameter in the function declaration, values that get sent when calling the function gets …