Question - 1
How many stages are there in React js life cycle
Answer- C
Question - 2
Which of following is used to pass data to a component from outside?
- PropTypes
- setState
- render with arguments
- props
Solutions
Answer- D
Question - 3
How do you access a function getData() from a h1 element in JSX?
- {getData()}
- ${getData()}
- {getData}
- ${getData}
Solutions
Answer- A
Question - 4
What happens when the following render() method executes?
render(){
let langs = ["PHP","ES6","JAVA"]
return (<div>
{langs.map(it => <p>{it}</p>)}
</div>)
}
- Error. Cannot use direct JavaScript code in JSX
- Error. Should be replaced with a for..loop for correct output
- Displays the list of languages in the array
- Displays nothing
Solutions
Answer- C
Question - 5
What function allows you to render React content in an HTML page?
- React.mount()
- ReactDOM.start()
- ReactDOM.render()
- React.render()
Solutions
Answer- C
Question - 6
Arbitrary inputs of components in React are called
Answer- B
Question - 7
How can you access the state of a component from inside of a member function?
- this.state
- this.values
- this.getState()
- this.prototype.stateValue
Solutions
Answer- B
Question - 8
Which of the following method is not a part of ReactDOM?
- ReactDOM.delete()
- ReactDOM.destroy()
- ReactDOM.unset()
- None of the above
Solutions
Answer- B
Question - 9
Which of the following is the correct data flow sequence of flux concept?
- Action->Dispatcher->View->Store
- Action->Dispatcher->Store->View
- Action->Store->Dispatcher->View
- None of the above
Solutions
Answer- B
Question - 10
For controlled components in react
- Source of truth is DOM
- Source of truth can be anything
- Source of truth is component state
- None of the above
Solutions
Answer- C
Question - 11
In relation to React js component lifecycle, which statement is true
- Only function component can have life cycle
- Only class components can have life cycle
- Both type of components can have life cycle
- None of above
Solutions
Answer- B
Question - 12
How can you set a default value for an uncontrolled form field?
- By using the value property
- By using the defaultValue property
- By using the default property
- It is assigned automatically.
Solutions
Answer- B
Question - 13
At the highest level, React components have lifecycle events that fall into
- Destruction
- Initialization
- State/Property Updates
- All the above
Solutions
Answer- D
Question - 14
Which method in a React Component should you override to stop the component from updating?
- willComponentUpdate
- shouldComponentUpdate
- componentDidUpdate
- componentDidMount
Solutions
Answer- B
Question - 15
What should the console read when the following code is run? const [, , animal] = ['Horse', 'Cow', 'Cat']; console.log(animal);
Answer- C
Question - 16
How do you handle passing through the component tree without having to pass props down manually at every level?
- React Send
- React Pinpoint
- React Router
- React Context
Solutions
Answer- D
Question - 17
What can you use to handle code splitting?
- React.split
- React.lazy
- React.memo
- React.fallback
Solutions
Answer- B
Question - 18
What is the children prop?
- a property that lets you pass components as data to other components
- a property that lets you pass data to child elements
- a property that lets you set an array as a property
- a property that adds child components to state
Solutions
Answer- A
Question - 19
When might you use React.PureComponent?
- when you do not want your component to have state
- when you have sibling components that need to be compared
- when you want a default implementation of shouldComponentUpdate()
- when you do not want your component to have props
Solutions
Answer- C
Question - 20
What is snapshot testing used for in react?
- It allows us to test Javascript objects
- It helps you write applications
- It provides clear, enduring assertions
- None of the above
Solutions
Answer- A
Practice more set questions