10 React Questions part 1
2 min readJan 29, 2022
1. How can you import and export components?
- export default ComponentName
- import ComponentName from
'components/ComponentName';
2. How can you optimize a React app?
1) useMemo hook memoizes
expensive data
2) PureComponent
and putting state down reduce
re-renders
3) lazy loading makes
the app load faster
3. How can you perform an automatic redirect?
With:
<Redirect to="/some-path" />
4. How do you create a React app?
- install Node,
- call npx create-react-app my-app,
- open the code in your favorite
code editor.
5. How do you memoize a component?
By wrapping a function returning
a component with React.memo.
React.memo will re-render the
component only when function
props change.