React.js Flashcards
What is React?
a JavaScript library for creating user interfaces
What is a React element?
object
How do you mount a React element to the DOM?
ReactDOM.render()
What is JSX?
syntax extension to JavaScript (JS plus some more).
-Transpilation step where JSX gets transpiled into JS
Why must the React object be imported when authoring JSX in a module?
In order to use the methods on the react object (ex. react.createElement)
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
Use babel loader and the plugin @babel/plugin-transform-react-jsx
What is a React component?
a JS function that accepts props as inputs and returns react elements
How do you define a function component in React?
function definition or a class, capitalize the names
How do you mount a component to the DOM?
ReactDOM.render()
What are props in React?
- Props is the shorthand for Properties in React.
- Props are read-only components which must be kept pure i.e. immutable.
- Props are always passed down from the parent to the child components throughout the application.
- A child component can never send a prop back to the parent component. This helps in maintaining the unidirectional data flow and are generally used to render the dynamically generated data.
How do you pass props to a component?
as a key=”value” pair inside react element
How do you write JavaScript expressions in JSX?
{ }
What Array method is commonly used to create a list of React elements?
array.prototype.map
What is the best value to use as a “key” prop when rendering lists?
ID number or name from data that distinguishes it from another piece of sibling data
How do you create “class” component in React?
class ComponentName extends React.Component { render() { } }