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?)
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...}>
);
}
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