0% found this document useful (0 votes)
48 views

React JS 15 Interview Qns

The major advantages of React include increased performance, ability to use on both client and server sides, improved readability through JSX, and easy integration with other frameworks. React is a library, not a full framework, so it can be difficult for novices and coding gets complex with inline templating. Browsers cannot read JSX directly, so it needs to be transformed to JavaScript using tools like Babel. Props are immutable components passed from parent to child components to maintain unidirectional data flow. useState allows adding state variables to functional components, like managing dynamic DOM elements. React Hooks enable using state and lifecycle methods in function components without classes. React Router allows adding new screen flows and syncing URLs with UI

Uploaded by

Azizul Hakim
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

React JS 15 Interview Qns

The major advantages of React include increased performance, ability to use on both client and server sides, improved readability through JSX, and easy integration with other frameworks. React is a library, not a full framework, so it can be difficult for novices and coding gets complex with inline templating. Browsers cannot read JSX directly, so it needs to be transformed to JavaScript using tools like Babel. Props are immutable components passed from parent to child components to maintain unidirectional data flow. useState allows adding state variables to functional components, like managing dynamic DOM elements. React Hooks enable using state and lifecycle methods in function components without classes. React Router allows adding new screen flows and syncing URLs with UI

Uploaded by

Azizul Hakim
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1. What are the major advantages of React?

Ans: The major advantages of React are:

• It increases the application’s performance


• It can be conveniently used on the client as well as server side
• Because of JSX, code’s readability increases
• React is easy to integrate with other frameworks like Meteor, Angular, etc
• Using React, writing UI test cases become extremely easy

2. What are the limitations of React?

Ans: Limitations of React are listed below:

• React is just a library, not a full-blown framework


• Its library is very large and takes time to understand
• It can be little difficult for the novice programmers to understand
• Coding gets complex as it uses inline templating and JSX

3. Why can’t browsers read JSX?

Ans: Browsers can only read JavaScript objects but JSX in not a regular JavaScript object. Thus,
to enable a browser to read JSX, first, we need to transform JSX file into a JavaScript object using
JSX transformers like Babel and then pass it to the browser.

4. What are Props?

Ans: Props is the shorthand for Properties in React. They are read-only components which must
be kept pure immutable. They are always passed down from the parent to the child components
throughout the application. A child component can never send a prop back to the parent
component. This help in maintaining the unidirectional data flow and are generally used to render
the dynamically generated data.
5. What is useState() in React?

Ans: The useState() is a built-in React Hook that allows you for having state variables in
functional components. It should be used when the DOM has something that is dynamically
manipulating/controlling.

In the below-given example code, The useState(0) will return a tuple where the count is the first
parameter that represents the counter’s current state and the second parameter setCounter
method will allow us to update the state of the counter.

6. What is React Hooks?

Ans: React Hooks are the built-in functions that permit developers for using the state and
lifecycle methods within React components. These are newly added features made available in
React 16.8 version. Each lifecycle of a component is having 3 phases which include mount,
unmount, and update. Along with that, components have properties and states. Hooks will allow
using these methods by developers for improving the reuse of code with higher flexibility
navigating the component tree.

Using Hook, all features of React can be used without writing class components. For example,
before React version 16.8, it required a class component for managing the state of a component.
But now using the useState hook, we can keep the state in a functional component.

7. What is React Router?

Ans: React Router is a routing library which allows you to add new screen flows to your
application, and it also keeps URL in sync with what’s being shown on the page.

8. Explain the use of ‘key’ in react list

Ans: Keys allow you to provide each list element with a stable identity. The keys should be
unique.

9. What is children prop?

Ans: Children props are used to pass component to other components as properties. You can
access it by using
{props.children}

10. What is Context?

Ans: React context helps you to pass data using the tree of react components. It helps you to
share data globally between various react components.

11. How is routing in React different from conventional routing?

Ans: Differences between the conventional routing and the routing in React can be shown using
the following aspects:

• Pages: Each view is considered as a new file in conventional routing while it is considered as
a single HTML entity in React.
• Navigation: In conventional routing, users have to move across web pages for viewing. In
React, the views are not refreshed as objects are re-issued to create new views.

12. What is the significance of Keys in React?

Ans. Keys are used in React to identify unique VDOM Elements with their corresponding data
driving the UI and help React identify which items have changed, are added, or are removed.
Keys should be a unique number or string.

13. What are refs in React?

Ans: ‘Refs’ is short for references in React. Refs are used to store a reference to a single React
element or a React component. This is later returned using the render function.

They are mainly used in the following scenarios:

• To initiate imperative animations


• To join third-party DOM libraries
• To manage focus and apply media playback

14. What are the components of Redux in React?


Ans: Redux consists of four main components as shown below:

• Action: An object that describes the call


• Reducer: The state change storage unit
• Store: the state and object tree storage
• View: Displays data provided by the store

15. How can you tell React to build in the production mode?

Ans: React can be coded to directly build into production by setting the process.env.NODE_ENV
variable to production. When React is in production, warnings and other development features
are not shown.

You might also like