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.
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.
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.
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".
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.
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
.
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.
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.
Excellent work!