Adding Redux Functionalities to the App
Learn about designing and implementing a Redux global state for a React Native app, focusing on managing user login/logout states and liked images.
We'll cover the following
We will start by designing the state structure and actions. When we have both, we will add reducers to tie everything together.
There’s a lot of work ahead of us, so let’s try to break it down into smaller chunks:
We will start by looking at the user state and how we could manage a user’s logged-in and logged-out state with a global state in Redux.
We will then do that same walkthrough for liked images in our app.
When we have successfully set up those two pieces of the global state, we will look at how we can combine them and use them in our app.
We will then create some actions to handle events in the app.
Once we have the state and the actions, we’ll take a brief look at how data can be fetched in an app with Redux.
Finally, we will be ready to get rid of the ReactJS context we used before for managing the state of our app.
User login state walkthrough
Let’s start with the user state. We will create a new file called store.js
where we will store our initial state slices. We will add this JavaScript object to that file:
Get hands-on with 1400+ tech skills courses.