React Flashcards
What is React?
A JS library for building UI’s
What is a React element?
An object that describes the element
How do you mount a React element to the DOM?
ReactDom.render(element, container)
What is JSX?
A JavaScript syntax extension
Why must the React object be imported when authoring JSX in a module?
JSX compiles into React.createElement
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
Babel transform react jsx
What is a React component?
A function that accepts a prop and returns a react element
How do you define a function component in React?
function FuncName(props){ return (<h1>hi</h1>); } function keyword followed by function name with parameter props.. inside code block return statement with element that represents DOM tags
How do you mount a component to the DOM?
ReactDom.render(, container)
What are props in React?
A javascript object
How do you pass props to a component?
function name with variable initialized to prop value
How do you write JavaScript expressions in JSX?
expression inside curly braces
How do you create “class” component in React?
class keyword FunctionName extends React.Component opening code block render() definition code block return react element
How do you access props in a class component?
this.props.element
What is the purpose of state in React?
Represents information on the elements current situation and allows it to be updated