React Flashcards
What is React?
a javascript library for building user interfaces
What is a React element?
an object that describes an element
How do you mount a React element to the DOM?
ReactDOM.render()
What is JSX?
syntax extension to JavaScript
Why must the React object be imported when authoring JSX in a module?
Since JSX compiles into calls to React.createElement, the React library must also always be in scope from your JSX code
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
npm install @babel/plugin-transform-react-jsx
What is a React component?
a JavaScript class or function that returns a React element
How do you define a function component in React?
function functionName( [props] ) { return [prop] }
How do you mount a component to the DOM?
ReactDOM.render( element, parent )
What are props in React?
When React sees an element representing a user-defined component, it passes JSX attributes and children to this component as a single object. We call this object “props”.
How do you write JavaScript expressions in JSX?
{ }
How do you create “class” component in React?
define a class that extends Component and has a render method
How do you access props in a class component?
this.props
What is the purpose of state in React?
to represent information about the component’s current situation to determine behavior
How to you pass an event handler to a React element?
assign it to the elements prop using { }