React Flashcards
What is a React element?
React element is an object that’s describes DOM node.
What is Babel?
Babel is a tool(complier) to convert ECMAScript 2015 code into a backwards compatible version.
What is a Plug-in?
Plug-in is a software that ads specific feature to an existing computer program
What is a Webpack loader?
Webpack loader is a plugin which transforms source code of module.
How can you make Babel and Webpack work together?
By using loader as plugin in webpack config.js (babel loader)
What is JSX?
It’s XML style extension to JavaScript language
Why must the React object be imported when authoring JSX in a module?
It needs to be available so we can call method on it.
This refers to - import React from ‘react’
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
To convert JSX into valid JavaScript we use plugin react jsx.
How do you mount a component to the DOM?
Adding is as a first parameter into ReactDOM.render method, second is DOM element where to mount it.
What are props in React?
Props in React are objects. Props are arguments pass to React components.
How do you pass props to a component?
We pass props to a component as key:value -> name=”Max”
How do you write JavaScript expressions in JSX?
Between curly bracers
How do you create “class” component in React?
Using keyword class MyComponent extends React.Component{ return () { content }}
How do you access props in a class component?
using this.props
What is the purpose of state in React?
It’s like data model, when you update it react change website
How you pass an event handler to a React element?
you pass event handler as a prop
What are controlled components?
Input elements that are controlled by react
What two props you must pass to an input, for it to be “controlled”?
value and onChange
What Array method is commonly used to create a list of React elements?
Map method
What is the best value to use as a “key” prop when rendering lists?
Whatever is unique should be use as a key, (id)
When does React call a component’s componentDidMount method?
Immediately after first render (inserted into DOM tree
Name three React.Component lifecycle methods.
ComponentDidMount, ComponentDidUpdate, render, constructor
How do you pass data to a child component?
As a props, from main component
What are React Hooks?
React Hooks are functions. Let as use state and other features in the functional components.