react Flashcards
What is React?
A JavaScript library for building user interfaces
How do you mount a React element to the DOM?
you use ReactDom.render(${element}, ${location you want to add it to)
What is a React Element?
an Object
What is JSX?
, JSX just provides syntactic sugar for the React.createElement(component, props, …children) function.
Why must the React object be imported when authoring JSX in a module?
Because React must be in scorp from your jsx code, since JSX Compiles into calls to React.createElement
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
use the @babel/plugin-transfform-react-jsx
What is a React component?
components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what shoudl appear on teh screen
How do you define a function component in React?
either function {Name}(prop/object){
return <h1> Hello, {prop.name]</h1>
}
How do you mount a component to the DOM?
ReactDOM.render
What are controlled components?
An input form element whose value is controlled by React
What two props must you pass to an input for it to be “controlled”?
onSubmit={} and onChange={}