React MCQ
- ReactJS is a JavaScript library originally developed by Facebook.
- it helps in building highly engaging single-page web apps.
- react JS helps in breaking down the complex into simpler components.
- NPX: It is an npm package that is expected to be done only once in a project.
- Folder structure:
- Readme.md: it is used to generate an HTML summary.
- .gitignore: files that you do not want to push in GitHub.
- public/index.html: HTML file of our react app. This is the page that will be loaded on starting the application.
- src/index.js: JS File corresponding to index.html file.
- src/app.js: The main component of any react app. it acts as a container for all other components.
- src/ app.css : Hills in injection styling in react app
- JSX: it allows to write HTML in JavaScript and place them in DOM without any child() or createElement() method.
- Components in react:
- they are nothing but reusable JavaScript function
- even if the component does not depend on each other, they merge inside a parent component to produce the final UI.
- Benefits:
- allows reusability of code
- makes it easier to find a tailor
React MCQs
When setState() is called inside render() method, which of the following events takes place?
duplicate key error
repetitive output happiness on the screen
nothing happens
stackoverflow error
State whether true or false: React.js covers only the view layer of the app.
True
False
The function which is called to render HTML to a web page in react?
ReactDOM_render()
render()
render_DOM()
DOM_HTML()
Total ways of defining variables in ES6 is?
1
2
3
4
Using which of the following command can prevent default behaviour at in react?
preventDefault()
avoidDefault()
revokeDefault()
None of the above
What are arbitrary inputs of components in react also known as?
Elements
Props
Keys
Ref
What happens if you render an input element with disabled = {false}?
it will be rendered as enabled
it will be rendered as disabled
it will not be rendered at all
None of the above
What is Babel?
JavaScript compiler
JavaScript interpreter
JavaScript transpiler
None of the above
What is ReactJS mainly used for building?
Database
Connectivity
User interface
Design platform
What is ReactJS?
Server-side framework
user interface framework
both a and b
none of the above
What is the functionality of a “webpack” command?
Runs react local development server
transfer files all the JavaScript down into one file
a module blunder
none of the above
What is used to handle code-splitting?
React.lazy
React.memo
React.fallback
React.split
When is useReducer used over useState in React component?
When we want to replace redux
when we want to break our production app
when we want to improve performance
none of the above
State whether true or false: React merges the objects you provide into the current state using setState().
True
False
Which company developed ReactJS?
Apple
Which of the following are two ways to handle data in react?
services and components
State and props
state and services
state and component
Which of the following function is used to change the state of react component?
this.setState()
this.state()
this.setChangeState()
None of the above
Which of the following is used in React.js to increase performance?
Virtual DOM
Original DOM
Both A and B
None of the above
Which of the following is used to access a function fetch() from h1 element in JSX?
<h1>${fetch()}</h1>
<h1>{fetch}</h1>
<h1>${fetch}</h1>
<h1>{fetch()}</h1>
Which of the following method is used to access the state of a component from inside of a member function?
this.prototype.stateValue
this,getState()
this.values
this.state
Which of the following port is the default where webpack-dev-server runs?
3000
3306
3030
8080
Which of the following terms commonly described react applications?
Imperative
Integrated
Declarative
closed
Who created React.js?
Jordan Mike
Jordan Walke
Tim Lee
Jordan Lee
Why is ref used?
to bind the function
to call a function
to directly access the DOM node
to refer to another JS file
Why is useLayoutEffect used?
To complete the update
to optimize for all devices
To change the layout of the screen
when you need the browser to paint before the effectors
How many elements can a valid react component return?
1
2
3
4
Among the corner which is a must-have for every ReactJS component?
renderComponent
SetinitialComponent
Render
All of the above
Among The following options, choose the one which helps react for keeping their data uni-directional?
DOM
Flux
JSX
Props
Among the following which acts as the input of class-based component?
Factory
Render
Class
props
Among the following which is used to create a class inheritance?
Inherits
Extends
Create
this
Choose the component which should be overridden to stop the component from updating?
componentDidUpdate
componentDidMount
willComponentUpdate
shouldComponentUpdate
Choose the correct data flow sequence of flux concept.
Action -> Dispatcher -> Store -> View
Action -> Dispatcher -> View -> Store
Action -> Store -> View -> Dispatcher
Dispatcher -> Action -> Store -> View
Choose the correct statement in the context of uncontrolled components in ReactJS?
source of truth can be anything
source of truth is a component state
source of truth is DOM
none of the above
Choose the functionality of setState?
Access the previous state before the setState operation.
invoke code after the setState operation is done
replace this date completely instead of the default merge actionnone of the above
none of the above
Choose the library which is most often associated with react?
Sinon
Chai
Jest
Mocha
Choose the method which is not a part of ReactDOM?
ReactDOM.createPortal()
ReactDOM.hydrate()
ReactDOM.destroy()
ReactDOM.findDOMNode()
Choose the method with refers to the parent class in ReactJS?
this()
super()
iniherits()
self()
ES6 stands for _________
ECMA 6
ECMAJavaScript 6
ECMAScript 6
EJavaScript 6
A state in React.js is also known as?
The internal storage of the component
External storage of the component
Permanent storage
All of the above
Identify the command used to create a react app.
npm install create-react-app
npm install -g create-react-app
install -g create-react-app
None of the above
Identify the one which is used to pass data to components from outside
Render with arguments
setState
PropTypes
props
Identify the smallest building block of React.JS.
Props
Elements
Components
None of the above
In MVC, what does React.js act as?
Model
Controller
View
Middleware
In react, the key should be?
Unique among his siblings only
unique in the DOM
Does not requires to be unique
all of the above
In which directory is react component saved?
vendor/js/components/
components/js
js/components
vendor/components
In which language is React.js written?
Python
JavaScript
Java
PHP
JSX stands for __________
Javascript XML
JSON XML
JSON
Javascript and AngularJS
React is a ___________
JavaScript framework
JavaScript library
both a and b
none of the above
State whether true or false: Props are methods into other components?
True
False
State whether true or false: React creates virtual DOM in memory.
True
False