LFZ React Quiz Flashcards
What is React?
A JavaScript library for building user interfaces
What is a React element?
Elements are the smallest building blocks of React apps.
How do you mount a React element to the DOM?
ReactDOM.render
What is JSX?
JSX produces React “elements”. Fundamentally, JSX just provides syntactic sugar for the React.createElement(component, props, …children)
Why must the React object be imported when authoring JSX in a module?
Because JSK is just syntactic sugar for React objects
What is a React component?
Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.
How do you define a function component in React?
Just like a function in JS, except you return JSX. The name must start with a capital letter
How do you mount a component to the DOM?
With ReactDOM.render
What are props in React?
arguments passed into React components
How do you write JavaScript expressions in JSX?
With curly braces
How do you create “class” component in React?
by creating a new class that extends react.component
How do you access props in a class component?
With this.props
What is the purpose of state in React?
To update an element
How to you pass an event handler to a React element?
provide a listener when the element is initially rendered.
What two props must you pass to an input for it to be “controlled”?
id and type