React Quiz
What advantages does ReacTJS have?
Increases the application's performance with VIrtualDOM JSX makes a code that is easy to read and write IT renders both on client and server side Easy to integrate with other frameworks(angular, backboneJS) since it is only a view library
JSX's features include..
JAS is faster as it performs optimization while compiling code to JavaScript JSX is a syntax notation for JavaScript XML JSX provides expressiveness of JavaScript along with HTML, like template syntax
What is ReactJS?
Library for building interaction interfaces
what method in a React component is called after the component is rendered for the first time?
componentDidUpdate
What is a common use for 'ref'?
to directly access a DOM node
What is the children prop?
A property that lets you nest components in other components
React separates the user interface into components. How are components combined to create a user interface?
By nesting commponents
How can you optimize performance for a function component that always renders the same way?
Wrap it in the React.memo higher-order component.
_____ can be done while multiple elements need to be returned from a component.
Wrapping
When rendering a list using the JavaScript map() method, what is required for each element rendered?
key
What command is used to start the React local development server?
npm start
What are two ways that data gets handled in React?
state & props
React can only render elements in the root document element
False
What is the default local host port that a React development server uses?
3000
What is the default local host port that a React development server uses?
5000
How can you combine the following arrays using the spread operator? const array1 = [1, 2, 3]; const array2 = [4, 5, 6];
const combined = [...array1, ...array2];
What type of element will be rendered from the following code? function Car() { return <h1>Ford Mustang</h1>; } const root = createRoot(document.getElementById('root')); root.render(<Car />);
h1
What is the correct syntax to import a component from React?
import { Component } from 'react'
What is the correct command to create a new React project?
npx create-react-app myReactApp
The arbitraty inputs of components are called____.
props
What is used to pass data to a component from outside?
props
React merges the object provided into the current state using___.
setState()
What method in a React Component should be overridden to stop the component from updating?
shouldComponentUpdate
What is a common use case for ref?
To directly access a DOM node
What props will be available to the following component? <Car {...props} />
all of them
Ref is used for returning an element or component returned by____.
render()
What tool does react use to compile JSX?
Babel
To develop and run React code, Node.js is required.
TRUE
What is state in React?
An internal data store (object) of an component.
Which operator can be used to conditionally render a React component?
&&
What will happen if you call setState() insdie render() method?
Stack overflow error
React component names must begin with an uppercase letter.
TRUE
The lifecycle methods are mainly used for ______.
freeing up resources
Why should you avoid copying the values of props into a component's state?
Because that would create two instances of the same state that could become out of sync
A copy of the 'real' DOM that is kept in memory is called what?
Virtual DOM
Which is NOT true about React Hooks' rules?
Hooks can be called in Class or Function components
Disadvantages of ReactJS
It is only a view layer, you have to plug in your code for Ajax requests, events and so on... The library is pretty large The learning curve can be slow
What does myReactApp refer to in the following command? npx create-react-app myReactApp
The name you want to use for the new App