React Quiz Questions Flashcards
What is React?
A JavaScript library for building user interfaces
What is a React element?
React elements are plain objects, and are cheap to create
How do you mount a React element to the DOM?
The render method of the ReactDom object
What is JSX?
A syntax extension to JavaScript
Why must the React object be imported when authoring JSX in a module?
So we can compile react and babel
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
You need the babel plugin-transform-react-jsx
What is a React component?
UI split into independent, reusable pieces
How do you define a function component in React?
Write a JavaScript function with an uppercase character to start
How do you mount a component to the DOM?
ReactDom render with the component passed as the tagName argument
What are props in React?
It is an object
How do you pass props to a component?
Putting a key value pair inside the component
How do you write JavaScript expressions in JSX?
By writing the expression within a set of curly braces
What Array method is commonly used to create a list of React elements?
The map method
What is the best value to use as a “key” prop when rendering lists?
A unique id within the dataset that was passed in
How do you create “class” component in React?
Extend the React.Component and declare a render method in the class
How to you pass an event handler to a React element?
A common pattern is for an event handler to be a method on the class
What is the purpose of state in React?
The purpose is to track the change in state
How to you pass an event handler to a React element?
By passing the event handler as a prop
What are controlled components?
An input form element whose value is controlled by React
What two props must you pass to an input for it to be “controlled”?
type and value