-
-
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? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
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 :/
Run fix:prettier
) Before submitting a pull request, please take a look at our [Contributing](https://github.com/getsentry/sentry-javascript/blob/master/CONTRIBUTING.md) guidelines and verify: - [ X ] If you've added code that should be tested, please add tests. - [ X ] Ensure your code lints and the test suite passes (`yarn lint`) & (`yarn test`).
This PR adds the external contributor to the CHANGELOG.md file, so that they are credited for their contribution. See #16106 Co-authored-by: s1gr1d <32902192+s1gr1d@users.noreply.github.com>
Before submitting a pull request, please take a look at our
Contributing guidelines and verify:
yarn lint
) & (yarn test
).