React Flashcards
What is Webpack?
It is a static module bundler for modern JavaScript applications (takes all the files and bundles them into one for your application)
What is the advantage of using Webpack (or a similar bundler)?
It internally builds a dependency graph from one or more entry points and then combines every module your project needs into one or more bundles, which are static assets to serve your content from.
What is Babel
Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments.
What is the advantage of using Babel (or a similar transpiler)?
So you can work on old applications using newer code/methods
What is React?
React is a way to let you build user interfaces out of individual pieces called components.
What is a React element?
A React element is what gets returned from components (a custom written DOM element)
How do you mount a React element to the DOM ?
Attaching/Appending/Rendering
What is JSX?
JSX is an extension to the JavaScript language syntax which provides a way to structure component rendering using syntax familiar to many developers commonly used in React
How does React use JSX to render components?
const root = ReactDOM.createRoot(document.getElementById(‘root’));
root.render(
<React.StrictMode>
<ComponentName></ComponentName>
</React.StrictMode>
);
What is a React component?
Independent and reusable bits of code
How do you define a component in React?
With a capital letter, and return a jsx
How do you mount a component to the DOM (or “render” a component)?
By attaching it to the root. calls the function when it sees it wrapped in <>. Takes the result of calling the function and puts it in the DOM.
What are props in React?
A type of object where the value of attributes of a tag is stored
How do you use props in a component?
By passing them as an attribute and setting their value as the value of the attribute
How do you write JavaScript expressions in JSX?
Within curly braces
How to you pass an event handler to a React component?
As an argument/prop
What is the naming conventions for event handlers?
Event names are written in camelCase
What are some custom event handler props a component may wish to define?
onClick, onSubmit, onChange
What is the naming convention for custom event handler props?
Usually with the prefix on*
What is an eventHandler?
A function that occurs when something is activates it
What is an eventHandler?
A function that occurs when something is activates it
What are hooks in React?
useState or any other function starting with “use”. Hooks are special functions that are only available while React is rendering.
What are “Rules of Hooks”? (if necessary, re-read the “Pitfall” box in State)
Only call hooks at the top level. Only call hooks from react functions. Call hooks from react function components. Call hooks from custom hooks.
What is the purpose of state in React?
To contain data or information about the component