React Flashcards

1
Q

Name some ways to optimize

A
  • bundle your build
  • utilizing memo/usememo/callback CORRECTLY for rerenders
  • lazy loading
    • React.Suspense and React.Lazy (can you give example?)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  • can you tell me how to use React.Lazy?
A
  • old way:

import LazyComponent from ‘./LazyComponent’;

  • new way:

const LazyComponent = React.Lazy(() => import(‘./LazyComponent’));

function MyComponent() {
  return (
    Loading...}>

);
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what do class components have that functional components do not?

A
  • error boundaries. using

static getDerivedStateFromError() to render a fallback UI after an error has been thrown

componentDidCatch() to log error information

How well did you know this?
1
Not at all
2
3
4
5
Perfectly