React.js Flashcards
What is React?
A JavaScript library for creating user interfaces. It is typically used with react-dom for web, and react-native for mobile.
What is a React element?
A React element is when the element is created using React.createElement.
How do you mount a React element to the DOM?
To mount a React element, ReactDOM.render() method is required. The React element and it’s container is needed for the arguments.
What is JSX?
JSX is a syntax extension to JavaScript. It is mainly used with React to help describe how the UI should look.
Why must the React object be imported when authoring JSX in a module?
.
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
Webpack and Babel must be installed to the devDependencies. The npm packages react and react-dom are also required. Then running the build script to compile it all.
What is a React component?
Components allow splitting the UI into independent pieces so they are more reusable and fit more situations.
How do you define a function component in React?
Function keyword followed by the function name followed by the code block that returns the JSX syntax.
How do you mount a component to the DOM?
By using the render method. The arguments would be the React element and the container which is the DOM query.
What are props in React?
.
How do you pass props to a component?
.
How do you write JavaScript expressions in JSX?
.
How do you create “class” component in React?
Class keyword followed by the function name followed by the extends keyword then React.Component. Curly braces for the code block that include render() being defined, and a code block inside that as well to return the React element being created.
How do you access props in a class component?
When using the props in a class component, the object this has to be used to define where props is coming from.
What is the purpose of state in React?
.