react Flashcards
What is React?
JavaScript library for creating user interfaces
What is a React element?
object that describes an element.
How do you mount a React element to the DOM?
ReactDOM.render()
What is JSX?
JavaScript syntax extension, provides a way to structure a component rendering using familiar HTML syntax.
Why must the React object be imported when authoring JSX in a module?
Because when you run Babel on JSX, you need the React object to create React element. So that you can run methods on it.
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
webpack bundles the modules, babel compiles, use babel-loader to connect webpack to babel.
What is a React component?
javascript function or a class. have to return react elements.
How do you define a function component in React?
function keyword, name of function, optional parameters, and return JSX expression.
How do you mount a component to the DOM?
ReactDOM.render
What are props in React?
props are objects. values for props are either strings or objects.
How do you pass props to a component?
react element name, props name = value
How do you write JavaScript expressions in JSX?
inside curly braces
How do you create “class” component in React?
you need a render method within the class component.
How do you access props in a class component?
using this
What is the purpose of state in React?
states the current situation. About what changes. Contain data or information about the component.