React.js Flashcards
What is React?
React is a JavaScript library for building user interfaces.
What is a React element?
A React Element is what gets returned from components.
It’s an object that virtually describes the DOM nodes that a component represents.
An element is a plain object describing a component instance or DOM node and its desired properties.
How do you mount a React element to the DOM?
By using ReactDOM.render
What is JSX?
JSX is an XML-like syntax extension to ECMAScript w/o any defined semantics.
It is called JSX, and it is a syntax extension to JavaScript.
Used to write HTML tags inside JavaScript.
JSX is an XML/HTML-like syntax used by React that extends ECMAScript so that XML/HTML-like text can co-exist with JavaScript/React code
Why must the React object be imported when authoring JSX in a module?
JSX works with React.render() or createElement(); belongs to React
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
Use babel loader and install the babel-plugin that transforms React JSX
What is a React component?
Conceptually, components are like JavaScript functions.
Components let you split the UI into independent, reusable pieces.
Think about each piece in isolation.
How do you define a function component in React?
Function Name (props) { return (rendered React elements) }
How do you mount a component to the DOM?
By using ReactDOM.render on the react element
What are props in React?
They are objects; Props stand for properties; used to pass data between React components
How do you pass props to a component?
’ ‘ if it’s a string and { } if not.
How do you write JavaScript expressions in JSX?
put them in curly braces
How do you create “class” component in React?
keyword class name keyword extends react.component { render() { return the react elements } }
How do you access props in a class component?
this.props
What is the purpose of state in React?
To keep track of values that will change over time