Skip to content

Commit

Permalink
Add redux-form type to AppDispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
simensma-fresh committed Dec 19, 2024
1 parent b65262f commit 0cdf85e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions services/common/src/redux/rootState.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { sharedReducer } from "@mds/common/redux/reducers/rootReducerShared";
import { configureStore } from "@reduxjs/toolkit";
import { configureStore, Dispatch } from "@reduxjs/toolkit";
import { loadingBarReducer } from "react-redux-loading-bar";

import type { TypedUseSelectorHook } from 'react-redux'
import { useDispatch, useSelector, useStore } from 'react-redux'
import type { FormAction } from 'redux-form';

export const getStore = (preloadedState = {}) =>
configureStore({
Expand All @@ -17,10 +18,14 @@ export const getStore = (preloadedState = {}) =>

export const store = getStore();

// Provide typed versions for global redux functions
/**
* Provide typed versions for global redux functions
**/

type RootState = ReturnType<typeof store.getState>;

export type AppDispatch = typeof store.dispatch;
// Infer the `RootState` and `AppDispatch` types from the store itself + make sure redux-form actions are captured as well.
export type AppDispatch = typeof store.dispatch & Dispatch<FormAction>;
export type AppStore = typeof store;

// Use throughout your app instead of plain `useDispatch` and `useSelector`
Expand Down

0 comments on commit 0cdf85e

Please sign in to comment.