File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change 1- import { useContext } from 'react'
2- import { ReactReduxContext } from '../components/Context'
1+ import { useContext , Context } from 'react'
2+ import { Action as BasicAction , AnyAction , Store } from 'redux'
3+ import {
4+ ReactReduxContext ,
5+ ReactReduxContextValue ,
6+ } from '../components/Context'
37import { useReduxContext as useDefaultReduxContext } from './useReduxContext'
8+ import { RootStateOrAny } from '../types'
49
510/**
611 * Hook factory, which creates a `useStore` hook bound to a given context.
712 *
813 * @param {React.Context } [context=ReactReduxContext] Context passed to your `<Provider>`.
914 * @returns {Function } A `useStore` hook bound to the specified context.
1015 */
11- export function createStoreHook ( context = ReactReduxContext ) {
16+ export function createStoreHook <
17+ S = RootStateOrAny ,
18+ A extends BasicAction = AnyAction
19+ // @ts -ignore
20+ > ( context ?: Context < ReactReduxContextValue < S , A > > = ReactReduxContext ) {
1221 const useReduxContext =
22+ // @ts -ignore
1323 context === ReactReduxContext
1424 ? useDefaultReduxContext
1525 : ( ) => useContext ( context )
16- return function useStore ( ) {
26+ return function useStore <
27+ State = S ,
28+ Action extends BasicAction = A
29+ // @ts -ignore
30+ > ( ) {
1731 const { store } = useReduxContext ( ) !
18- return store
32+ // @ts -ignore
33+ return store as Store < State , Action >
1934 }
2035}
2136
You can’t perform that action at this time.
0 commit comments