From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Store setup and API

Store setup and API

Hello and welcome back. Now we are going to set up our store. For this, we can have a folder created inside our source folder. We'll name it app and inside this we can have a store.ts file. We will export a constant of store and we can create it by the configureStore method from Redux toolkit. This is going to have a reducer object. We can provide the reducers later on, once we create them. After that, we have to export few types, so we can use them in the useSelector and useDispatch functions will declare a root state, it will be of return type, type of store.getState. And similarly, you need to have another type for appDispatch and it will be of type of Now, we have to go in the main.tsx to connect this store with our application. Over here, we can remove it for the time being and add the provider, which we are going to get from Redux, React Redux. We can have the store equals to this store which we just created. Inside this, we are going to have the query client provider and we are…

Contents