Our experts have gathered these React.js MCQs through research, and we hope that you will be able to see how much knowledge base you have for the subject of React.js by answering these multiple-choice questions.
Get started now by scrolling down!
In relation to stateful React components, which of the following statements is correct?
i) React triggers the event handlers in the bubble phase, by default.
ii) For event handlers, CamelCase naming convention is used by React.
iii) React actually attaches event handlers to the DOM nodes themselves.
A.
Only statements i) and ii) are correct.
B.
Only statement ii) is correct.
C.
Both statements i) and iii) are correct.
D.
All statements i), ii) and iii) are correct.
A. React Addons
B. Redux
C. React Motion
D. React Fire
Which of the following options is the correct signature of the unmountComponentAtNodeO method that is used for removing a mounted React component from the DOM and Cleaning its event handlers and state?
A.
ReactDOM.unmountComponentAtNode(container)
B.
ReactDOM.unmountComponentAtNode(container, component)
C.
ReactDOM.unmountComponentAtNode(component, children)
D.
ReactDOM.unmountComponentAtNode(element, container)
A. jsx
B. reactx
C. reactxml
D. jsxml
A. componentDidUpdate()
B. shouldComponentUpdate()
C. componentwillUpdate()
D. componentWillReceiveProps()
E. None of the above.
In the below given code snippet, which of the following functions should be placed in place of "???" so that the values of numbers array are doubled?
const numbers= [2, 4, 6, 8, 10];
const increased = ???((numbers) => number * 2);
console.log(increased);
A.
numbers.map
B.
updateState
C.
numbers.transform
D.
updateState.map.numbers
In relation to React renderIntoDocument() function, which of the following options should be present globally before importing React?
i) window
ii) window.document
iii) window.document.createElement
A.
Only option i).
B.
Only options i) and ii).
C.
Only options ii) and iii).
D.
All options i), ii) and iii).
A. testRenderer.update(element,Options)
B. testRenderer.update(type, element)
C. testRenderer.update(element)
D. testRenderer.update(element, type, Options)
Which of the following statements is! are correct about the ReactJS features?
1. In a ReactJS application, all components have a state.
2. ReactJS virtual DOM can differentiate between a static and a dynamic element.
3. Rendering is possible using a virtual DOM even without dirty checking.
A.
Only1 and 2
B.
Only1 and 3
C.
Only 2 and 3
D.
All 1, 2, and 3
In relation to React test utilities, which of the following options is used for finding all DOM elements of components in the rendered tree that have DOM components with the matching tag name?
A.
scryRenderedDOMComponentsWithTag()
B.
findRenderedDOMComponentWithTag()
C.
findRenderedComponentWithType()
D.
scryRenderedComponentsWithType()
Which of the following methods is first invoked in the component lifecycle's updating phase and is called when a component receives new properties from its parent component?
A.
shouldComponentUpdate()
B.
componentWillUpdate()
C.
componentWillReceiveProps()
D.
render()
While using React, which of the following commands is used for creating a new project?
A.
npm install -a create-react-app
create-react-app example-app
B.
npm install -g create-react-app
create new react-app example-app
C.
npm install -g create-react-app
create-react-app example-app
D.
npm install -a create-react-app
create new app example-app
Which of the following statements is/are correct about ReactJS?
i) It is mandatory to use JSX in React development.
ii) One-way data flow is implemented by React.
A.
Only statement i) is correct.
B.
Only statement ii) is correct.
C.
Both statements i) and ii) are correct.
D.
Neither statement i) nor ii) is correct
A. It is a JavaScript object that is passed from a parent element to a child element but not the other way around.
B. It is a JavaScript object that is passed from a child element to a parent element but not the other way around.
C. It is a JavaScript object that is either passed from a parent element to a child element or from a child element to a parent element.
D. It is used for creating a ReactClass.
A. React.Component
B. React.PureComponent
C. Both options i) and ii).
D. Neither option i) nor ii).
A. getDefaultProps()
B. componentDidMount()
C. componentwillMount()
D. getlnitialState()
A. It is used for controlling the contents of the container node that the user passes in.
B. It is used for modifying the container node.
C. It can be used for returning a reference to the root ReactComponent instance.
A. This.props
B. this.state
C. None of the above.
A. Actions
B. Reducers
C. Root Component
D. Store
A. Mutable state is only updated using the setstate() method.
B. In the React select tag, only a single value can be passed into the value attribute.
C. Both statements a and b are correct.
D. Neither statement a nor b is correct.
Consider the current state as following:
{
isHidden: true,
title: 'React new Example'
}
Suppose the this.setState(nextState) method is called and the current state is updated to the following:
{
isHidden: false
}
Which of the following is the correct way in which React will merge these two states?
A.
{
isHidden: false
}
B.
{
isHidden: true,
title: ' '
}
C.
{
isHidden: true,
title: 'React new Example'
}
D.
{
isHidden: false,
title: 'React new Example'
}
A. Only one parameter is passed and that is state.
B. Two parameters are passed and that are state and action.
C. Only one parameter is passed and that is action.
D. Two parameters are passed and that are state and ReactElement
E. Three parameters are passed and that are state, ReactElement and action.
While using React, keys help in the identification of which of the following options?
i) New added items.
ii) Removed items.
iii) Updated items.
iv) Total number of items.
A.
Only options i) and iv).
B.
Only options i). ii) and iv).
C.
Only options i), ii) and iii).
D.
All options i). ii), iii) and iv).
Which of the following statements is/are correct about the eslint-plugin-jsx-aiiy plugin?
i) It is used for providing AST tinting feedback regarding accessibility issues in the JSX.
ii) This plugin is provided by the Create React App with a subset of activated rules.
A.
Only statement i).
B.
Only statement ii).
C.
Both statements i) and ii).
D.
Neither statement I) nor ii).
A. selected
B. name
C. value
D. It does not use any attribute but use its Children elements, instead.
A. isCompositeComponent()
B. isElementOnype()
C. isCompositeComponentWithType()
D. mockComponent()
Choose True or False
In relation to React Flux, only the root component should be aware of a redux.
A.
True
B.
False
A. With a state.
B. Without a state.
C. Both options a and b.
D. Neither option 8 nor b.
A. Stream
B. StreamTweet
C. Collection
D. None of the above.
A. ReactDOM.render(ReactElement. ReactText. DOMElement, callback);
B. ReactDOM.render(ReactText, DOMEIement, callback);
C. ReactDOM.render(ReactElement. DOMElement. callback);
D. ReactDOM.render(ReactElement, Reacttext, callback);
A. collectionTweets
B. state
C. SynthetiCEvent
D. this.props
A. Shallow Renderer
B. Test Renderer
C. React
D. None of the above.
A. state and select function
B. state and action
C. Only action
D. Only select function
A. componentWillMount()
B. componentWillUpdate()
C. Both a and b
D. Neither a nor b
While validating React component properties. a custom validator function is used for validating the tweet property. Which of the following parameters are passed to this function?
i) properties
ii) propertyName
iii) media
iv) componentName
A.
All options i), ii), iii) and iv).
B.
Only options i), ii) and iii).
C.
Only options ii), iii) and iv).
D.
Only options i), ii) and iv).
A. ReactDOM.createPortaI(element, child, container)
B. ReactDOM.createPortal(container, component)
C. ReactDOM.createPortaI(child, container)
D. ReactDOM.createPortal(container)
A. Select
B. It
C. Render
D. bundle
A. componentDidUpdate()
B. componentwillUpdate()
C. render()
D. shouldComponentUpdate()
A. sudo npm install —g jest Cli
B. sudo npm install —devjest —g
C. sudo npm install —g jest
D. sudo npm install --Save-g jest
A. npm install react-addons-css-transition-group
B. npm install react-save-css-transition-group
C. npm install react --save-addons-css-transition-group
D. npm install react--addons.css.transition.group
A. C:\Users\username\Desktop\reactApp>index.html
B. C:\Users\username\Desktop\reactApp>create index.html
C. C:\Users\username\Desktop\reactApp>touch index.html
D. C:\Users\username\Desktop\reactApp>createElement index.html
A. npm install react-redux
B. npm install react-redux -save
C. npm install --save react-redux
D. npm install --save –redux for react
Which of the following is the correct syntax of React function that will enforce that names are written with all uppercase letters?
A.
handleChange(event)[
this.setState({valuezeventtarget.value.toUpperCase0));
}
B.
event.handleChange(
this.setState([value= eventtarget.value.toUpperCase0]);
}
C.
handleChange.event[
this.setState([value:target.value.toUpperCase0));
}
D.
handleChange[
event.set$tate([value: this.target.value.toUpperCaseOI);
}
Which of the following is the correct syntax for creating a ReactElement of type h1 having the properties object and a ReactText as its only child?
A.
[
render: function 0{
return React.createElement([ className: 'header'. 'hl'}, 'React
Component‘);
}
}
B.
[
render: function 0{
return React.createElement('h1'. [ className: ‘header' ], ‘React
Component‘);
I
I
C.
{
renderfunction 0[
return React.createElement('h1', className: 'header'. "React
Component“);
I
D.
[
render: function 0{
return React.createElement(React
Component= 'h1', [ className: 'header‘ },
I;
I
Which of the following options is the correct syntax for creating a new folder named Dispatcher in a project's ”/snapterest/ source/exampleDispatch directory?
A.
var Dispatcher = require('fiux‘).Dispatchen
module.exports = new Dispatchero;
B.
var Dispatcher = require(fiuxDispatcher);
module.exports = new DispatcherO;
C.
var Dispatcher = require Dispatcher('flux').;
module exports = new Dispatcher();
D.
var Dispatcher = require new fiux.Dispatcher;
module.exports = new Dispatchero;
A. React.Children.map(function[children, thisArg)
B. React.Children.map(children, function[(thisArg)])
C. React.Children.map(object, children, function[(thisArg)])
D. React.Children.map(children)
A. React.Children.count(children)
B. React.Children.map(children)
C. React.Children.only(children)
D. React.Children.toArray(children)
A. Test
B. type
C. props
D. All of the above.
Which of the following commands are used for installing React and React DOM? (Consider reactApp as the root folder.)
A.
C:\Users\username\Desktop\reactApp>npm install react -save
C:\Users\username\Desktop\reactApp>npm install react dom -save
B.
C:\Users\username\Desktop\reactApp>npm install react
C:\Users\username\Desktop\reactApp>npm install react dom --save
C.
C:\Users\username\Desktop\reactApp>npm install react --save
C:\Users\username\Desktop\reactApp>npm install react.dom --save
D.
C:\Users\username\Desktop\reactApp>npm install react --save
C:\Users\username\Desktop\reactApp>npm install react-dom --save
A. []
B. {}
C. ()
D. It does require the use of any kind of brackets.