1
- import { readonly , ref , toRaw , watch } from 'vue'
1
+ import { shallowReadonly , shallowRef , toRaw , watch } from 'vue'
2
2
import { ContextKey } from '../provider/context'
3
3
import {
4
4
createReduxContextComposition ,
5
5
useReduxContext as useDefaultReduxContext ,
6
6
} from './use-redux-context'
7
- import type { DeepReadonly , InjectionKey , Ref , UnwrapRef } from 'vue'
7
+ import type { InjectionKey , ShallowRef } from 'vue'
8
8
import type { EqualityFn } from '../types'
9
9
import type { VueReduxContextValue } from '../provider/context'
10
10
@@ -41,7 +41,7 @@ export interface UseSelector<StateType = unknown> {
41
41
< TState extends StateType = StateType , Selected = unknown > (
42
42
selector : ( state : TState ) => Selected ,
43
43
equalityFnOrOptions ?: EqualityFn < Selected > | UseSelectorOptions < Selected > ,
44
- ) : Readonly < Ref < DeepReadonly < UnwrapRef < Selected > > > >
44
+ ) : Readonly < ShallowRef < Selected > >
45
45
46
46
/**
47
47
* Creates a "pre-typed" version of {@linkcode useSelector useSelector}
@@ -83,7 +83,7 @@ export function createSelectorComposition(
83
83
equalityFnOrOptions :
84
84
| EqualityFn < Selected >
85
85
| UseSelectorOptions < Selected > = { } ,
86
- ) : Readonly < Ref < DeepReadonly < UnwrapRef < Selected > > > > => {
86
+ ) : Readonly < ShallowRef < Selected > > => {
87
87
const { equalityFn = refEquality } =
88
88
typeof equalityFnOrOptions === 'function'
89
89
? { equalityFn : equalityFnOrOptions }
@@ -93,7 +93,7 @@ export function createSelectorComposition(
93
93
94
94
// TODO: Introduce wrappedSelector for debuggability
95
95
96
- const selectedState = ref ( selector ( store . getState ( ) as TState ) )
96
+ const selectedState = shallowRef ( selector ( store . getState ( ) as TState ) )
97
97
98
98
watch (
99
99
( ) => store ,
@@ -104,7 +104,7 @@ export function createSelectorComposition(
104
104
return
105
105
}
106
106
107
- selectedState . value = data as UnwrapRef < Selected >
107
+ selectedState . value = data
108
108
} )
109
109
110
110
onCleanup ( ( ) => {
@@ -116,7 +116,7 @@ export function createSelectorComposition(
116
116
} ,
117
117
)
118
118
119
- return readonly ( selectedState )
119
+ return shallowReadonly ( selectedState )
120
120
}
121
121
122
122
Object . assign ( useSelector , {
0 commit comments