Skip to content

Commit 631f71e

Browse files
To keep correct typescript type, use "Proxy" instead of plain object. @s1gr1d I am wondering if we can do better than accessing the index [0] directly ?
1 parent 9cd9056 commit 631f71e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/react/src/redux.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,13 @@ function createReduxEnhancer(enhancerOptions?: Partial<SentryEnhancerOptions>):
160160
}
161161

162162
const store = next(sentryWrapReducer(reducer), initialState);
163-
return {
164-
...store,
165-
replaceReducer(nextReducer: Reducer<S, A>) {
166-
store.replaceReducer(sentryWrapReducer(nextReducer))
167-
},
168-
}
163+
164+
// eslint-disable-next-line @typescript-eslint/unbound-method
165+
store.replaceReducer = new Proxy(store.replaceReducer, {
166+
apply: function (target, thisArg, args) {
167+
target.apply(thisArg, [sentryWrapReducer(args[0])]);
168+
}
169+
})
169170

170171
return store;
171172
};

0 commit comments

Comments
 (0)