React Flashcards
What is React?
a JS library for building user interfaces.
component based.
What is a React element?
an object that functions as a DOM element
How do you mount a React element to the DOM?
ReactDOM.render(element, container[,callback])
What is JSX?
js syntax extension
Why must the React object be imported when authoring JSX in a module?
bc it gets transformed into react.create element
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
we need babel-loader and the babel plugin transform react jsx
What is a React component?
a reusable piece of React that describes a piece of the UI
any fxn that starts with CAPITAL LETTER
& returns JSX
How do you define a function component in React?
function Welcome(props) { return <h1>Hello, {props.name}</h1>; }
How do you mount a component to the DOM?
ReactDOM.render(element, mountingElement);
What are props in React?
how we pass data into a component.
they look like attributes
How do you pass props to a component?
key value pair on jsx component that resembles an attribute
How do you write JavaScript expressions in JSX?
wrap them with curly brace
How do you create “class” component in React?
class className extends React.Component { render( ) { return (jsx) } }
***RENDER METHOD IS REQUIRED!
How do you access props in a class component?
this.props.propertyName
class CustomButton extends React.Component
What is Component?
Component
is a class that contains props and we are EXTENDING its functionality and thus inherit all the methods of parent class (like prototype almost).
This is how you can access this.props.propertyName in your custom class