What is React?
A declarative component-based view library that helps one to build a UI.
What would be a React Framework?
By using React, Redux, and React router, we have ll the necessary to make a single page application.
Important Thing #1: React uses JSX, what is JSX?
JSX is a javascript syntax extension that somewhat resembles HTML/XML
Important Thing #2: React is based on the virtual DOM.
The virtual DOM is memory of an ideal tree that is represented by the javascript the developer writes that is later compared with the real DOM and synced with it via a process called reconciliation.
Current demand for React experts is?
React has roughly 6-10 times more job openings than Vue and 2-4 times more job openings than Angular. Why then does Vue have more stars than react on GitHub, but way fewer job openings??? No inkling why this is…..
Comparing React, Angular and Vue - who is behind their development?
React = Facebook, Angular = Google, Vue = open source.
Components can be either a function or a class. What is the difference?
Class has state and can use refs, lifecycle, and hooks whilst a function component is stateless.
What are the 2 types of class components and what is the difference between them?
Component and PureComponent. A PureComponent does a shallow comparison of props and state (reduced overhead), and Component will make full comparisons. Component can be used with shouldComponentUpdate.
Name the 7 react lifecycle methods.
Constructor(props)
componentDidMount()
componentWillUnmount()
componentDidUpdate(prevProps, prevState, snapshot)
shouldComponentUpdate(nextProps, nextState)
getSnapshotBeforeUpdate()
componentDidCatch(error, info)
Name 2 extra methods that are static.
static getDerivedStateFromError(error) statis getSnapshotBeforeUpdate(props, state)
Describe Constructor(props)
Describe componentDidMount()
Describe componentWillUnmount()
Describe componentDidUpdate(prevProps, prevState, snapshot)
Describe shouldComponentUpdate(nextProps, nextState)
Describe getSnapshotBeforeUpdate()
Can be used for keeping some information about current DOM, e.g., current scroll position which later can be reused within componentDidUpdate to restore the position of the scroll.
Describe componentDidCatch(error, info)
Describe static getDerivedStateFromError(error)
Describe static getSnapshotBeforeUpdate(props, state)
What are Props?
Props are properties that are passed to the component which later can be reused within it for displaying information/business logic and such:
import React, { Component } from ‘react’;
export default class App extends Component {
render() { return (
<div>
</div>
); } }const HelloWorld = (props) => <div>Hello {props.name}</div>
Tell more about Props.
What is state?
State, on the other hand, is a local state that can be modified, but indirectly by using this.setState
Describe SetState
SetState is a method to change local state object (by doing a shallow merge), and after that, the component responds that by rerendering itself. Be aware that after setState is used, the this.state property won’t reflect the changes mentioned in function right away (it has an asynchronous nature) as a few instances of setState might be batched together due to optimization. It
What is the React Context API?