REACT Flashcards
What is React?
a JS library/framework for building user interfaces
What is a React element?
a JavaScript Object that describe what a DOM element should loop like
How do you mount a React element to the DOM?
calling root.render(element)
what is the difference between a library and a framework
inversion of control
What is Babel?
a javascript compiler that can convert modern JS or other plugins to something more backwards compatible
What is a Plug-in?
external software add-ons that help customize stuff
What is a Webpack loader?
it runs through code and turns it into backwards compatible JS before sending it to Webpack
How can you make Babel and Webpack work together?
by downloading babel-loader from NPM
What is JSX?
a syntax extension for JS to work with REACT to help structure the UI
Why must the React object be imported when authoring JSX in a module?
because JSX produces REACT elements
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
with architecture plugins
What is a React component?
a function or class that returns or defines a react element
How do you define a function component in React?
function Name(props) { return }
How do you mount a component to the DOM?
query for an anchor point, assign it as a root of ReactDOM,
call root.render() and pass as the argument
What are props in React?
objects
arbitrary imputs(arguments) for react components
How do you pass props to a component?
by defining them as a key: value pair inside the react element
How do you write JavaScript expressions in JSX?
inside curly braces
How do you create “class” component in React?
class ‘name’ extends React.component {
prototypes
}
How do you access props in a class component?
this.prop.name
What is the purpose of state in React?
to track changes over time
How to you pass an event handler to a React element?
What are controlled components?
an input form element who’s value is controlled by React
What two props must you pass to an input for it to be “controlled”?
value and onChange handler
What Array method is commonly used to create a list of React elements?
map
What is the best value to use as a “key” prop when rendering lists?
a unique identifier
When does React call a component’s component.didMount method?
immediately after the component is rendered into the DOM tree
Name three React. Component lifecycle methods.
component. didMount(), component.didUpdate(),
component. willUnmount()
How do you pass data to a child component?
as a prop