-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(react): Fix Redux integration failing with reducer injection #16106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
fix(react): Fix Redux integration failing with reducer injection #16106
Conversation
Override replaceReducer functiont so any lazy loaded injection will reinsert the sentry reducer in the chain
Add a test to verify that redux enhancer is still calling setContext with updated store avec reducer being replaced
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @AntoineDuComptoirDesPharmacies thanks for contributing!
I made an adjustment to your PR title for better readability and requested a review from @s1gr1d (as requested in the issue). Please feel free to add any details to your PR description (if necessary). I also started CI for you (needs an approval since you're a first-time contributor).
Will leave the rest up to Sigrid.
Thanks again!
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 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this PR! I like the clean approach with the Proxy.
Please don't forget to run prettier as the CI complains about it.
// eslint-disable-next-line @typescript-eslint/unbound-method | ||
store.replaceReducer = new Proxy(store.replaceReducer, { | ||
apply: function (target, thisArg, args) { | ||
target.apply(thisArg, [sentryWrapReducer(args[0])]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw your question here: LeComptoirDesPharmacies@631f71e
I am wondering if we can do better than accessing the index [0] directly ?
Not really as we need to use the first argument :/
Before submitting a pull request, please take a look at our
Contributing guidelines and verify:
yarn lint
) & (yarn test
).