Skip to content

Instantly share code, notes, and snippets.

@ttarlov
Last active April 27, 2020 23:33
Show Gist options
  • Save ttarlov/5069242ba7801feb566b8fb004477fc0 to your computer and use it in GitHub Desktop.
Save ttarlov/5069242ba7801feb566b8fb004477fc0 to your computer and use it in GitHub Desktop.
Mod 3 Pre-Work

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

Biggest differentiator between framework and library is "who calls who"? Library is a collection of code that you can call on
at any time from your own code. Like Jquery, you can use built in methods with your own code to accomplish certain things. 
Framework is bound by rules and things need to be done in a certain way. Framework calls your code instead of you calling its code. 

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

The biggest benefit of using a framework is ability to easily keep UI in sync with data. When using plan vanilla JS you have to 
manually write code that makes sure your UI and data stays in sync which can be labor intensive and error prone. By using a framework 
the framework takes care of that problem, as long as you follow the rules of the framework and do things properly.

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

Component is a piece of reusable code that lets you split the UI into independent reusable pieces. There are two types of components 
in React: 1. Functional- these are simply JS functions that take optional "props" (properties) object and returns a React element. 
Class- class component is defined using a JS class syntax. The biggest difference between class and fn components is that class components
have ability to have "state". Fn components are simpler to write and easier to test. However they are limited in their abilities comparted to
class components. 

What are React "props?"

"Props" is a special keyword in React. It stands for "Properties". Props is an object and is used as an argument to pass data
between parent and child  React components. Important things to keep in mind is that data in the props object only flows one    way from parents to child components and also the data is immutable (read-only). Props are used to make your functions dynamic and more reusable. Its similar to arguments in JS functions.  

What is React "state?"

State is a special object that holds dynamic data. State can change based on the user actions or certain events. State is private and belongs to the component it was initialized in. However it can be passed to a child component using props. You should never change state directly. State should only be changed using a special setStage() method this way React will know that State was changed and will be able to properly render it in the UI. State should not be overused as it will impact performance. 

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

A concept that describes data flow in React. Where data is passed in props from parent to child component and actions like events are communicated back up the chain via passing of arguments into parent components functions. 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment