Skip to content

Instantly share code, notes, and snippets.

@jaypeasee
Last active November 30, 2020 21:35
Show Gist options
  • Save jaypeasee/8398f0041527dce731df6100906cdc58 to your computer and use it in GitHub Desktop.
Save jaypeasee/8398f0041527dce731df6100906cdc58 to your computer and use it in GitHub Desktop.

Mod 3 Prework

Turing, 2011 Inning

JP Carey

What is a "data model", and how does it relate to the DOM in a front-end application?

The data model is (ideally) a centralized place within your JavaScript that controls the state of the application. The DOM (Document Object Model) should always reflect the data model and never the other way around. Usually, the DOM will need to update immediately after changes are made to the data model. That way, what is displayed and what is happening "under the hood" are synced up.

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

When using a library you call the pieces of code you want to use or refer to. However, when using a framework the framework does the calling to the code, not you. Therefore, frameworks inherently have more built-in rules that need to be followed in order to properly use them. Often times, a framework can consist of a collection of libraries and it will rarely exist (if ever) the other way around.

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

Frameworks make your applications more scalable, efficient and easier to maintain because they "automatically" keep state and UI synced. The alternative vanilla JavaScript, requires statically updating UI separately after the state when any change is made to the application. This leaves too much room for error, it's tedious, and slow.

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

A Component is a reusable block of code that represents a piece of an application. Components can have multiple elements within them. The state and UI are synced in a component by storing the data model and "DOM" within them. Therefore there should be no minrepresentation between what is displayed and what is happening "under the hood".

What is JSX?

JSX is HTML-like code snippets that can be used to build React components. It is important to note that JSX is neither HTML or JavaScript but it is written like HTML (with elements and tags), AND it can take in JavaScript to make the display dynamic.

What are React "props?"

Props stands for properties. They are similar to parameters from functions in how they are used and why they are helpful. Props can be passed in component instances to dynamically define elements or just pieces of elements within those instances. They are passed from a parent component (where the instance is made) and used in a child component (where the "outline" of the component is executed). Additional note: You cannot/should not change the value of props.

What is React "state?"

State is an object with properties that represent data that can change on a component. It is initialized in the constructor of a child class component but can be used in any of that class' methods. State can be inserted into component elements so that the display renders dynamically on the component itself. By so doing, state and UI are synced.

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

It means to explain that in React, parent components can pass down data to their child components through props of instances and then the actions are passed back up when the code in the child component is executed so that the parent can execute its code.

@wvmitchell
Copy link

Excellent work!

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