1- import { readonly , ref , toRaw , watch } from 'vue'
1+ import { shallowReadonly , shallowRef , toRaw , watch } from 'vue'
22import { ContextKey } from '../provider/context'
33import {
44 createReduxContextComposition ,
55 useReduxContext as useDefaultReduxContext ,
66} from './use-redux-context'
7- import type { DeepReadonly , InjectionKey , Ref , UnwrapRef } from 'vue'
7+ import type { InjectionKey , ShallowRef } from 'vue'
88import type { EqualityFn } from '../types'
99import type { VueReduxContextValue } from '../provider/context'
1010
@@ -41,7 +41,7 @@ export interface UseSelector<StateType = unknown> {
4141 < TState extends StateType = StateType , Selected = unknown > (
4242 selector : ( state : TState ) => Selected ,
4343 equalityFnOrOptions ?: EqualityFn < Selected > | UseSelectorOptions < Selected > ,
44- ) : Readonly < Ref < DeepReadonly < UnwrapRef < Selected > > > >
44+ ) : Readonly < ShallowRef < Selected > >
4545
4646 /**
4747 * Creates a "pre-typed" version of {@linkcode useSelector useSelector}
@@ -83,7 +83,7 @@ export function createSelectorComposition(
8383 equalityFnOrOptions :
8484 | EqualityFn < Selected >
8585 | UseSelectorOptions < Selected > = { } ,
86- ) : Readonly < Ref < DeepReadonly < UnwrapRef < Selected > > > > => {
86+ ) : Readonly < ShallowRef < Selected > > => {
8787 const { equalityFn = refEquality } =
8888 typeof equalityFnOrOptions === 'function'
8989 ? { equalityFn : equalityFnOrOptions }
@@ -93,7 +93,7 @@ export function createSelectorComposition(
9393
9494 // TODO: Introduce wrappedSelector for debuggability
9595
96- const selectedState = ref ( selector ( store . getState ( ) as TState ) )
96+ const selectedState = shallowRef ( selector ( store . getState ( ) as TState ) )
9797
9898 watch (
9999 ( ) => store ,
@@ -104,7 +104,7 @@ export function createSelectorComposition(
104104 return
105105 }
106106
107- selectedState . value = data as UnwrapRef < Selected >
107+ selectedState . value = data
108108 } )
109109
110110 onCleanup ( ( ) => {
@@ -116,7 +116,7 @@ export function createSelectorComposition(
116116 } ,
117117 )
118118
119- return readonly ( selectedState )
119+ return shallowReadonly ( selectedState )
120120 }
121121
122122 Object . assign ( useSelector , {
0 commit comments