React Flashcards
What is React?
a javascript library for building user interfaces
What is a React element?
an object that the user can see
How do you mount a React element to the DOM?
render method of the reactDOM object
What is JSX?
syntax extension to JS, allows users to write HTML elements in JS and place them in the DOM without createElement()/appendChild() methods
Why must the React object be imported when authoring JSX in a module?
React library must be within the scope as you are calling things from it
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
webpack takes babel loader with plugin-transform-react-jsx to translate jsx to javascript and compile into another file
What is a React component?
function (class) that returns react elements
How do you define a function component in React?
same as JavaScript function definition
How do you mount a component to the DOM?
call reactDOM.render(, DOM)
What are props in React?
props are objects which are arbitrary inputs
How do you pass props to a component?
add it as a parameter in the function and call it within the function definition as {props}
How do you write JavaScript expressions in JSX?
within curly brackets { }
How do you create “class” component in React?
class className extends React.Component { render() { } }
How do you access props in a class component?
this.props
What is the purpose of state in React?
hold information that is managed within the component (like variables in a function)
State is an object that determines how that component renders and behaves