soapbox/store/configureStore --> soapbox/store, add custom Hooks

remove-makegetotheraccounts
Alex Gleason 2022-03-14 18:01:09 -05:00
rodzic a91fe1db91
commit a801a8a7c8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
5 zmienionych plików z 30 dodań i 23 usunięć

Wyświetl plik

@ -27,7 +27,7 @@ import { INTRODUCTION_VERSION } from '../actions/onboarding';
import { preload } from '../actions/preload';
import ErrorBoundary from '../components/error_boundary';
import UI from '../features/ui';
import configureStore from '../store/configureStore';
import { store } from '../store';
const validLocale = locale => Object.keys(messages).includes(locale);
@ -39,8 +39,6 @@ const isInstanceLoaded = state => {
return v !== '0.0.0' || fetchFailed;
};
export const store = configureStore();
// Configure global functions for developers
createGlobals(store);

Wyświetl plik

@ -0,0 +1 @@
export { useAppSelector } from './useAppSelector';

Wyświetl plik

@ -0,0 +1,5 @@
import { TypedUseSelectorHook, useSelector } from 'react-redux';
import { RootState } from 'soapbox/store';
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;

Wyświetl plik

@ -0,0 +1,23 @@
import { composeWithDevTools } from '@redux-devtools/extension';
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import errorsMiddleware from './middleware/errors';
import soundsMiddleware from './middleware/sounds';
import appReducer from './reducers';
export const store = createStore(
appReducer,
composeWithDevTools(
applyMiddleware(
thunk,
errorsMiddleware(),
soundsMiddleware(),
),
),
);
// Infer the `RootState` and `AppDispatch` types from the store itself
// https://redux.js.org/usage/usage-with-typescript
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;

Wyświetl plik

@ -1,20 +0,0 @@
import { composeWithDevTools } from '@redux-devtools/extension';
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import errorsMiddleware from '../middleware/errors';
import soundsMiddleware from '../middleware/sounds';
import appReducer from '../reducers';
export default function configureStore() {
return createStore(
appReducer,
composeWithDevTools(
applyMiddleware(
thunk,
errorsMiddleware(),
soundsMiddleware(),
),
),
);
}