W7D1 Flashcards

1
Q

What is lodash?

A

It is JS utility library and npm-package that provides many useful helper functions for solving common problems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is lodash merge?

A

It is a quick and effective way to deep dup an object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is lodash union?

A

It creates an array of unique values in insertion order from 2 given arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is flux?

A

Flux is a front-end application pattern developed to used with React. It provides a unidirectional data flow, which affords more predictability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an Action

A

It is a simple object that at minimum maintains a ‘type’. It begins a flows of data in Flux.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an Action type?

A

It indicates the type of change to be performed on the application’s state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Dispatcher

A

is a mechanism for distributing actions to a Flux application store and a pseudo bank/library of actions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Store

A

It represents the entire state of the application. Also responsible for updating the state of the application whenever it receives an action.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

View

A

It is responsible for rendering the user interface and it can create actions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the flow of flux?

A

Store will check the dispatcher for any actions and change the state. It will than pass the changed state to the view. If the view has an action, it will pass that action to the dispatcher and the store will check the dispatcher again.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is redux?

A

A node package that facilitates a particular implementation of Flux.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are 3 principles of Redux?

A
  1. The entire state of App is stored in single JS object, which is stored in a single store.
  2. The only way to change the state of the applicatin is to dispatch an action.
  3. Pure Functions aka Reducers are the only ones to change state.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does a reducer receive? What does it return?

A

Receives Current State and an action and return the new state

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the reducer first initialized with?

A

An undefined state

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is Reducer Composition?

A

It is the concept of splitting up reducers into multiple reducers handling separate, independent slices of the global state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is combineReducers() used for?

A

When using Reducer Composition, it is important use combineReducers. It combines multiple Reducers and returns a single reducer. It is important to do this because createStore only takes one reducer as an argument.

17
Q

What does combineReducers take as an argument?

A

It takes an argument of an object with keys mapped to reducers that handle a single portion of state.

18
Q

How do we create a store?

A

We import the createStore method from redux and a root reducer file. We declare a const of store and define it with the function createStore(rootReducer).

ex:
import {createStore} from ‘redux’;
import rootReducer form ‘./reducers/root_reducer/’

const store = createStore(rootReducer)

19
Q

How do you define an action creator?

A

You create a const of an action and assign it an object. It must hold the key of ‘type’ with a value of const and any following payloads. And you want to export both.

ex:

export const ADD_FRUIT = "ADD_FRUIT";
export const addOrange = {
	type: ADD_FRUIT,
	fruit: "orange"
};
20
Q

What is prop-threading?

A

It is an anti-pattern of nesting components and a deeply nested component does not have access to the store.

21
Q

What is Provider?

A

Provider is a component imported from react-redux, which will wrap an entire App inside of it and will give that entire App’s components, even its deeply nested components, access to the store without the use of prop-threading.

22
Q

How do you implement Provider for the ‘APP’?

A
// root.jsx
import React from 'react';
import { Provider } from 'react-redux';
import App from './app.jsx';

const Root = ({ store }) => (

);

export default Root;

23
Q

Where is the store created?

A

The store is not created in store.js. store.js just holds the function to create a store. The store is created in the entry file.

24
Q

What is the connect()?

A

connect gives components access to the store context, which converts the store context into a store prop

25
Q

What are the two arguments connect needs?

A

mapStateToProps, mapDispatchToProps

26
Q

mapStateToProps

A

It tells connect() how to map the state into your component’s props. It takes the store’s state and returns an object containing the relevant props for your component.

27
Q

mapDispatchToProps

A

It is a a function that accepts the store’s dispatch method and returns an object containing functions that can be called to dispatch actions to the store, which are then passed as props to your component.

28
Q

What is the purpose of a presentational component vs a container?

A

Presentational Components are responsible for how things look, and containers are responsible fore how things work?

29
Q

How do containers work?

A

They connect the store to the components it wraps around.

30
Q

What are selectors?

A

Selectors are functions that are passed the app’s state and return information from the application state in a specified form.

31
Q

What do you use selectors for?

A

We use them to format different slices of state.