index.tsx 782 B

123456789101112131415161718192021222324252627
  1. import { configureStore } from '@reduxjs/toolkit'
  2. import { Provider } from 'react-redux'
  3. import { useDispatch as useDispatchRaw, useSelector as useSelectorRaw } from 'react-redux'
  4. import { sceneReducer } from './scene'
  5. import type { TypedUseSelectorHook } from 'react-redux'
  6. export const store = configureStore({
  7. reducer: {
  8. scene: sceneReducer
  9. }
  10. })
  11. export type StoreState = ReturnType<typeof store.getState>
  12. export type AppDispatch = typeof store.dispatch
  13. export type AppSelector = TypedUseSelectorHook<StoreState>
  14. export const useDispatch = useDispatchRaw<AppDispatch>
  15. export const useSelector: AppSelector = useSelectorRaw
  16. export const AppStore = ({ children }: { children: any }) => (
  17. <Provider store={store}>
  18. { children }
  19. </Provider>
  20. )
  21. export default store