Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
June 18, 2021 04:19 pm GMT

React Interview Questions - Basic

Lets Begin with some of the basic ReactJs Interview Questions

1> How does React Work ?

Ans. React creates a virtual DOM. when there is any state changes in the DOM a diffing Algorithm runs to check what has changed in the in the virtual DOM. Next Reconciliation takes place where the where it udpates the DOM with the Difference.

2> What is Context ?

Ans. Context provides a way to pass data through the component tree without having to pass props down manually at the every level.

3> what is props in react ?

Ans. Props accept values in the component that are passed down to a child component.

primary purpose of props in react is to provide following component functionality :

  1. pass custom data to your react component
  2. Trigger state changes
  3. use via this.props.reactProp inside Component's render() method.

4> what is the use of refs ?

Ans. Refs provide a way to access DOM nodes or React elements created in the render method.
They should be avoided in most cases, however, they can be useful when we need direct access to DOM element or an instance of a component.

Refs are created using React.createRef() and attached to React elements via the ref attribute.

Ex. class MyComponent extends React.Component {
constructor(props) {
super(props);
this.myRef = React.createRef(); }
render() {
return

; }
}

5> what is JEST ?

Ans. Jest is a javascript unit testing framework made by facebook based on jasmine and provides automated mock creation and a jsdom environment. It's often used for testing React Components.

6> what are the advantages of ReactJs ?

Ans. 1> Increases the applications performanec with Virtual Dom
2> JSX makes code easy to read and write
3> it renders both on client and server side
4> Easy to integrate with other frameworks
5> Easy to write UI test case and integration with tools such as JEST.

7> How would you write an inline style in React ?

Ans.

8> What is React ?

Ans. React is an open source Javascript library created by facebook for building complex, interactive UIs in web and mobile applications. React's core purpose is to build UI components; It is often referred to as just the "V" (view) in
an "MVC" architecture.

9> What are major features of ReactJs ?

Ans. The major features of ReactJs are follows,

. It uses VirtualDOM instead RealDOM considering that RealDOM manipulation are expensive.
. Support server-side rendering.
. Follows Unidirectional data flow or data binding.
. Uses reuseable/composable UI components to develop the view

10> Where in a React component should you make an AJAX request ?

Ans. componentDidMount is where an AJAX request should be made in a React component.

This method will be executed when the component "mounts" (is added to the DOM) for the first time.

11> what is the difference between state and props?

Ans. The state is a data structure that starts with a default value when a Component mounts. It may be mutated across time, mostly as a result of user events.

Props (short for properties) are a component's configuration. They are received from above and immutable as far as the component receiving them is concerned.

12> What is the difference between a presentational component and a container component ?

Ans. Presentational components are concerned with how things look.
Container components are more concerned with how things work.

Thanks For Reading :)


Original Link: https://dev.to/skj4ua/react-interview-questions-basic-1ja1

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To