Skip to content

Instantly share code, notes, and snippets.

@rubyr
Created April 30, 2020 20:53
Show Gist options
  • Save rubyr/128c723028a2567f5b1c4f000c4d259d to your computer and use it in GitHub Desktop.
Save rubyr/128c723028a2567f5b1c4f000c4d259d to your computer and use it in GitHub Desktop.

What is a "framework?" And how does it differ from a "library?"

A framework is something you use in your code that does much of the routine work for you (most often, updating the DOM). A library is a set of features you can use in your code, but it doesn't necessarily replace or upgrade too many things.

Why should we consider using a framework over vanilla JS like you have been doing in mods 1 and 2?

Using a framework is so much easier than using vanilla JS. It allows you to abstract parts of code that you don't need to worry about, like dom manipulation and state handling. Using a library allows you to use less headspace for things you don't need to worry about, and instead focus on what's actually important.

What is a "component" in React? Why is it useful to have components?

A component is a block of code that has something to render. It can also contain a state, data, props, or really anything else - it's just a class that has some extra features. Components are useful because they allow us to abstract data into separate objects and just pass down what the object needs - it doesn't matter what it does with it, all we need to worry about is what to give it.

What are React "props?"

Props are the way react passes data around within the application. Prop is short for property, it's an attribute you add onto a component that the component can then access. They're useful for sharing data or methods.

What is React "state?"

State is a special object for every component. When the state is updated, React knows to re-render that component, and only that component gets re-rendered, which means the applications stay light and easy on the cpu. Other than that, they're just another way of storing data within a component.

What does "data down, actions up" mean in React?

When you create a React app, the "circle of life" goes as such - Data is stored in the highest level component that it needs to be, and is passed down through those components. When an action happens, for example a button is pressed, the component holding that button deals with the press, sending what it needs to upwards towards its parents (such as an input value or another piece of data) who can then adjust their state and data accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment