DEV Community

Cover image for 10 React Interview Questions Part 1️⃣
Tom Smykowski
Tom Smykowski

Posted on

10 React Interview Questions Part 1️⃣

Image description

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.

6. How do you pass data between components?

  • from parent to child with props,
    and in reverse with callbacks

  • other ways: inversion of control,
    Context API, state management

7. What are fragments?

Fragments let you group a list of
elements without adding extra
nodes to the DOM by wrapping
them with or <>.

8. What are portals in React?

Portals allow you to render children
into a DOM node that is not part of
the normal component hierarchy.
Syntax: createPortal(children,
popup);

9. What are uncontrolled components?

HTML elements are uncontrolled by
default because the DOM stores the
data. When we bind a value and
events to store the state in React,
a component becomes controlled.

10. What differs ES6 from ES5?

With ES6 (ES2015) we use import
and export, not 'require' and
'module.exports'. We don't use
createClass, getInitialState or the
'function' keyword.

The questions come from STJ: React Interview Questions Deck. It is a deck of flashcards and also a game that helps to prepare for a React tech interview.

If you’d like me to publish another set of questions please upvote, follow and comment.

Top comments (0)