React Flashcards
What is React?
React is a JavaScript library for creating user interfaces.
What is a React element?
It’s an object that virtually describes the DOM nodes that a component represents.
How do you mount a React element to the DOM?
reactDom.Render
Store react element into a variable and include it in the element argument of the ReactDom.render
What is JSX?
a syntax extension to JavaScript. JSX produces React “elements”.
It’s used for implementing react components in javascript that look like HTML
Why must the React object be imported when authoring JSX in a module?
If you forget to import React, it will be undefined and the createElement call will fail.
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
Install webpack and babel in terminal, create a build “webpack” script,
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?
Define it like any other function but takes in props for parameter have it return a tag with text content
How do you mount a component to the DOM?
ReactDOM.render and encase the component in a self closing tag with a root destination
What are props in React?
Props are arguments passed into React components
How do you pass props to a component?
Use name of the function and Name of the prop = “ “
How do you write JavaScript expressions in JSX?
Put the javascript in between curly braces and put it somewhere in jsx
What is the purpose of state in React?
It’s used represent an information about the component’s current situation.
How to you pass an event handler to a React element?
Use premade attributes in JSX elements such as onClick