Shake things up with Redux#405

Kevin Valias
2 min readOct 13, 2020

Discuss in words something you learned in class today or this week.

-Protected Routes- component is the blueprint for all protected routes in the application. If the user is logged in, go on and display the component in question; otherwise, redirect the user to sign-in page. Additionally, we can define the logic of isLogin utility function separately in utils folder.

What is Redux?

-Redux is a predictable state container for JavaScript applications. It helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test. Simply put, Redux is a state management tool.

What is ‘Store’ in Redux?

-Redux is a state container for JavaScript apps, often called a Redux store. It stores the whole state of the app in an immutable object tree. To create a store the createStore(reducer, [initialState], [enhancer]) function is used to create a new store. It takes three arguments: reducer — A reducing function.

How is state changed in Redux?

-The only way to update a state inside a store is to dispatch an action and define a reducer function to perform tasks based on the given actions. Once dispatched, the action goes inside the reducer functions which performs the tasks and return the updated state to the store. This is what Redux is all about.

What is the difference between a Presentational component and a Container component?

-As a way to simplify the distinction, we can say presentational components are concerned with the look, container components are concerned with making things work. On the other hand this is a container component. It manages and stores its own data, and uses the presentational component to display it.

What is the second argument that can optionally be passed to setState and what is its purpose?

-A callback function which will be invoked when setState has finished and the component is re-rendered.

What is your opinion of currently popular frameworks/libraries? List and provide your thoughts.

-I personally love React & Redux. React is an amazing library which allows a user to re-use components and Redux can change the state of those components by triggering an action which re-renders the static representation your component to create a dynamic feel to your App.

Austin Coding Academy

--

--