Reactjs Flashcards
What is this tag syntax called?
const element = <h1>Hello, world!</h1>;
JSX
React separates concerns with loosely coupled units called “components” that contain both.
Components
React DOM uses which naming convention?
Since JSX is closer to JavaScript than to HTML, React DOM uses camelCase property naming convention instead of HTML attribute names.
TRUE OR FALSE: By default, React DOM escapes any values embedded in JSX before rendering them.
By default, React DOM escapes any values embedded in JSX before rendering them. Thus it ensures that you can never inject anything that’s not explicitly written in your application. Everything is converted to a string before being rendered. This helps prevent XSS (cross-site-scripting) attacks.
What is an element?
Elements are the smallest building blocks of React apps.
An element describes what you want to see on the screen
Elements are what components are “made of”,
<div></div>
Why do we call this a “root” DOM node?
We call this a “root” DOM node because everything inside it will be managed by React DOM.
Conceptually, components are like ____________.
Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.
Always start component names with a capital letter.
True
All React components must act like pure functions with respect to their props.
True
What are three things you should know about setState()?
- Do Not Modify State Directly
For example, this will not re-render a component:
// Wrong
this.state.comment = ‘Hello’;
- State Updates May Be Asynchronous
- State Updates are Merged
Why do we need to ‘import React from “react”’ in our files?
Because the JSX syntax in defined in React
If I were to console.log(page) in index.js, what would show up?