Skip to content

Commit 2abd9a1

Browse files
committed
avoid bind
1 parent dadfca9 commit 2abd9a1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/toolkit/src/createSlice.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -917,11 +917,11 @@ function wrapSelector<State, NewState, S extends Selector<State>>(
917917
selectState: Selector<NewState, State>,
918918
injected?: boolean
919919
) {
920-
function wrapper(this: Slice, rootState: NewState, ...args: any[]) {
921-
let sliceState = selectState.call(this, rootState)
920+
function wrapper(rootState: NewState, ...args: any[]) {
921+
let sliceState = selectState.call(slice, rootState)
922922
if (typeof sliceState === 'undefined') {
923923
if (injected) {
924-
sliceState = this.getInitialState()
924+
sliceState = slice.getInitialState()
925925
} else if (process.env.NODE_ENV !== 'production') {
926926
throw new Error(
927927
'selectState returned undefined for an uninjected slice reducer'
@@ -931,7 +931,7 @@ function wrapSelector<State, NewState, S extends Selector<State>>(
931931
return selector(sliceState, ...args)
932932
}
933933
wrapper.unwrapped = selector
934-
return wrapper.bind(slice) as RemappedSelector<S, NewState>
934+
return wrapper as RemappedSelector<S, NewState>
935935
}
936936

937937
interface ReducerHandlingContext<State> {

0 commit comments

Comments
 (0)