-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add Missing Else to enhanceEndpoints Function #2386
Add Missing Else to enhanceEndpoints Function #2386
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 2e71d34:
|
For example, `enhanceEndpoints` can be used to modify caching behaviour by changing the values of `providesTags`, `invalidatesTags`, and `keepUnusedDataFor`: | ||
|
||
```ts | ||
const enhancedApi = api.enchanceEndpoints({ |
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.
It looks like CI may have failed due to this line:
https://app.netlify.com/sites/redux-starter-kit-docs/deploys/629d1fee7ab8150008c71b33#L301
I will take a closer look and fix this!
8e94b5a
to
787a30f
Compare
✅ Deploy Preview for redux-starter-kit-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Thank you for looking deeper into this! I think the test is enough - to be honest, I just forgot about the existence of that test :) I've tweaked the example a bit so it works without the |
Thanks for the updates and finding a way to remove the pesky |
Overview
Addresses #2334 .
This pr adds a missing
else
to theenhanceEndpoints
function to improve the clarity of the function. It also adds an example of using it to the documentation.Regarding the original issue:
Based on my understanding of
Object.assign
, passing a function as an assign will return a copy of the original object with no modifications. I created a codesandbox to demonstrate it (forgive me if there is a better template to use for such a simple example). As a result, the function won't affect the endpoint as the code currently is written. Let me know if I am misunderstanding the issue though, or if my premise is incorrect.Here is the code snippet again for reference:
redux-toolkit/packages/toolkit/src/query/createApi.ts
Lines 275 to 285 in 64a30d8
Even if the lack of an
else
will not cause a bug, it still does not make much sense to callObject.assign
when a function is passed, because it does not do anything. So, I still added theelse
in this pr for clarity and readability.The issue asked for tests as well, however when I went to adds tests I realized I was mostly duplicating a test that was already in the test suite:
redux-toolkit/packages/toolkit/src/query/tests/createApi.test.ts
Lines 457 to 501 in 64a30d8
I am happy to add more tests 🤓 , but I wondering what test cases may remain for this. I removed my test change from this pr because I didn't want to add more weight to the codebase without adding any testing value.
Lastly, is there a way for me to preview the docs changes in the format they are rendered? I wanted to provide a before/after screenshot but I am probably missing a very obvious set of steps to get it up and running!CI did it for me 😍 (and I figured out how to do it locally as well)Thanks for creating this package, and taking the time to read this wall of text ✌🏻 😄