React Flashcards
What is Webpack?
a tool that bundles your javascript files/modules
How do you add a devDependency to a package?
install –save-dev
What is an NPM script?
a command that you can use to execute multiple command line commands
How do you execute Webpack with npm run?
npm run webpack
How are ES Modules different from CommonJS modules?
more compact, different syntax …
What kind of modules can Webpack support?
.
What is a React element?
an object
How do you mount a React element to the DOM?
ReactDOM.render(…)
What is Babel?
a toolchain used to convert ES6 code to older versions of it
What is a Plug-in?
adds a feature to an existing program
What is a Webpack loader?
transformations that allow you to pre-process files as you import(load) them
How can you make Babel and Webpack work together?
babel loader
What is JSX?
Syntax extension to JavaScript. Allows you to write HTML expressions in React
Why must the React object be imported when authoring JSX in a module?
it is not in the native library.
JSX compiles to calls of the createElement method
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
need to install the babel transform-react-jsx plugin
What is a React component?
javascript function that is independent and reusable - returns a react element
How do you define a function component in React?
just write a function that accepts a props parameter and returns a react object - must start with Capital letter
How do you mount a component to the DOM?
ReactDOM.render()
What are props in React?
custom inputs you can pass into react functions (properties)
How do you pass props to a component?
when defining the react element, add an attribute to it - ex:
How do you write JavaScript expressions in JSX?
inside curly braces
What Array method is commonly used to create a list of React elements?
map()
What is the best value to use as a “key” prop when rendering lists?
something from the dataset that gives it a unique identifier amongst the list item’s siblings
How do you create “class” component in React?
use: extends React.Component
How do you access props in a class component?
this.props
What is the purpose of state in React?
keeps track of changes over the passage of time
the component will re-render when state is changed
How to you pass an event handler to a React element?
define it in when creating the react element as a prop