React Flashcards
What is React?
React is a JavaScript library for creating user interfaces.
What is a React element?
A React element is an object representation of a DOM node.
How do you mount a React element to the DOM?
ReactDom.render
What is JSX?
a syntax extension to JavaScript. We recommend using it with React to describe what the UI should look like.
Why must the React object be imported when authoring JSX in a module?
JSX just provides syntactic sugar for the React.createElement(component, props, …children) function
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
babel-loader and the plugin
What is a React component?
Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.
How do you define a function component in React?
function CustomBtn() { return Click Me!; }
“return jsx”
How do you mount a component to the DOM?
ReactDOM.render
What are props in React?
It is an object which stores the value of attributes of a tag and work similar to the HTML attributes.
How do you pass props to a component?
Define a function and pass it as a parameter
How do you write JavaScript expressions in JSX?
wrap them with curly braces
How do you create “class” component in React?
class and extends
How do you access props in a class component?
this.props.whateverhere
What is the purpose of state in React?
represent an information about the component’s current situation