REACT JS QUIZ
1 .
If you want to import just the Component from the React library, what syntax do you use?

Correct Answer : Option (D)

import { Component } from 'react'
  Show Answer
2 .
If a function component should always render the same way given the same props, what is a simple performance optimization available for it?

Correct Answer : Option (A)

Wrap it in the React.memo higher-order component.
  Show Answer
3 .
How do you fix the syntax error that results from running this code?
const person =(firstName, lastName) =>
       {
            first: firstName,
            last: lastName
        }
console.log(person("jhon", "Wolson"))

Correct Answer : Option (A)

Wrap the object in parentheses.
  Show Answer
4 .
If you see the following import in a file, what is being used for state management in the component?

import React, {useState} from 'react';

Correct Answer : Option (D)

React Hooks
  Show Answer
5 .
Using object literal enhancement, you can put values back into an object. When you log person to the console, what is the output?
const name = 'Venkat';
const age = 30;
const person = { name, age };
console.log(person);

Correct Answer : Option (B)

{name: "Venkat", age: 30} 
  Show Answer
6 .
How do you access a function fetch() from a h1 element in JSX?

Correct Answer : Option (A)

<h1>{fetch()}</h1> 
  Show Answer
7 .
What happens when the following render() method executes?
render(){
   let langs = ["Ruby","ES6","Scala"]
     return (<div>
       {langs.map(it => <p>{it}</p>)}
     </div>)
 }

Correct Answer : Option (C)

Displays the list of languages in the array
  Show Answer
8 .
How do you write an inline style specifying the font-size:12px and color:red; in JSX

Correct Answer : Option (B)

style={{fontSize:'12px',color:'red'}} 
  Show Answer
9 .
Which method in a React Component should you override to stop the component from updating?

Correct Answer : Option (B)

shouldComponentUpdate
  Show Answer
10 .
What happens when you call setState() inside render() method?

Correct Answer : Option (D)

Stack overflow error

Explanation : Call to setState() invokes render(). Calling it inside render is suicidal. It gets into an infinite loop

  Show Answer