REACT Flashcards
What is Webpack?
Webpack, grabs only the files the web browser needs and bundles them for quick easy use for the browser.
What is the advantage of using Webpack (or a similar bundler)?
Make things quicker and less downloading.
What is Babel?
Converts modern javascript into older javascvript.
What is the advantage of using Babel (or a similar transpiler)?
Allows us to develop javascript with modern rules but still allow older browsers to run.
What is React?
A framework to create reusable and interactive components.
What is a React element?
Custom written DOM element or group of.
How do you mount a React element to the DOM?
ReactDom
What is JSX?
JSX allows you to write, html in your javascript.
How does React use JSX to render components?
React runs all the fance DoM javascript methods.
What is a React component?
A html element or group of elements.
How do you define a component in React?
In a function with uppercase name that returns JSX.
How do you mount a component to the DOM (or “render” a component)?
By calling a function that returns JSX and is capital letters.
How to you pass an event handler to a React component?
Through it’s props
What is the naming convention for event handlers?
handleWhatever
What are some custom event handler props a component may wish to define?
Whatever they need?
What is the naming convention for custom event handler props?
onClick
What are hooks in React?
Any function starting with use that run while React is rendering.
What are the “Rules of Hooks”?
They must be called at the top level of a components or inside other hooks.
What is the purpose of state in React?
Maintain a variable as a state variable through renders.
Why can’t we just maintain state in a local variable?
Local variable do not persist through a render and changes to a variable don’t trigger a render. Also to make a component reusable you need a variable for each one.
What two actions happen when you call a state setter function?
Triggers a render, and updates a ‘cache’ or future value of the variable for after the render.
When does the local state variable get updated with the new value?
After the render is done.
How do controlled components differ from uncontrolled components?
The parent controls the child, or uncontrolled does it itselfs.