-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix: devtools to patch api.setState #172
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 c981883:
|
@TkDodo Here's your example with this change. https://codesandbox.io/s/agitated-stonebraker-bg7bi |
Okay, this f4c6239 should be much better. |
Thanks! From what I can tell, the code looks good. I understand that we cannot change the interface of |
@TkDodo Did you try the sandbox?
By |
Yes, I did try the codesandbox and it works fine for me. I made a test case for testing it in combination with the redux middleware: https://codesandbox.io/s/react-forked-xbjg9 From what I can see, the
I mean |
Thanks!
Maybe, I can fix it in this PR.
Yeah, totally correct. Let's leave it as a limitation because types would be too messy, if we were to support this. (I think it's technically possible.) If you are adventurous, it might be able to do like this: const useStore = create(devtools((set, get, api) => {
api.setState = set
return {
// ...
}
})) |
https://codesandbox.io/s/react-forked-6czzc Oh, but this will stop logging if you use |
yes, sounds good.
Yes, I am actually doing that already as a workaround until this PR lands:
hm, how would you even do that ? In the example, we only pass the |
This 99a9f64 is probably better, even thought it's unlikely that people use |
@TkDodo Would you do the final test? If it's OK, we release it. |
using the |
Oops! |
Reverted. 😄 |
👍 |
Close #171.
There are a few technical issues:1. we need to fix types in vanilla.ts and index.ts too.2. we can't chain middleware that only patchesset
.Due to 2), I'm a bit hesitant to this approach.