-
-
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(types)(middleware/devtools): fix action type in devtools's setState #1183
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ea70466
added payload to setState() in devtools middleware
lucasrabiec 9bbf125
adjusted tests
lucasrabiec bcc5e0b
changed payload to any property name
lucasrabiec 8e79ade
adjusted docs
lucasrabiec 3bb1fc8
prettier readme.md
lucasrabiec ce2a715
adjusted for extends
lucasrabiec 50ce327
adjusted immer's setState
lucasrabiec a6b8c35
Revert "adjusted immer's setState"
lucasrabiec f8fe591
changed order of immer and devtools in tests
lucasrabiec f2f4ef8
added test for action with payload type in immer/devtools
lucasrabiec ebbee73
removed unnecessary test
lucasrabiec ccb85bf
Update tests/middlewareTypes.test.tsx
dai-shi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think it's good to have the payload key something other than "payload" to imply "payload" is not a special key, it can be anything...
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's Redux-style logging and the payload is a special key for action in Redux Devtools. IMO it would be great to keep it like that while using Redux Devtools.
Here is a link to the conversation on the pmndrs DC: https://discord.com/channels/740090768164651008/740093228904218657/1006824679111135343
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.
In what way is it special? Like how does redux devtools treat
payload
key different fromcount
key?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.
The main goal of this PR is logging the action's payload as the
payload
field, not any field name the user wants. To be consistent with the Redux convention (https://github.com/redux-utilities/flux-standard-action).Ok, I am getting now that you want to abstract from it, right? The question is whether we want to have it consistent or to have whatever field's name the user wants but I think we should leave this decision for Zustand's owner.
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.
Okay so as I guessed redux devtools doesn't treat payload key in any special way.
Users allowed to choose the convention they want to follow, the one you've linked is just one of the many styles out there, it's not required. The only requirement and constraint of a redux action is that it must have a
type
property.I understand that you want to impose an convention for your logger, but the code being edited here affects everyone, and we can't impose a non-required convention for everyone.
Sure, just giving my two cents.
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.
I don't want to impose some of my conventions. I assumed that is a well-known standard and it would be nice to be consistent with it, but not. And it's okay.
I will add
[key: string]: unknown;
but you mention:Could you elaborate? Is there the other way to achieve that?
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.
Ah I missed this comment, it's mostly resolved now but I'll reply for sake of completeness...
I never said it was "your" convention, I'm well aware about FSA, but not everyone uses it. My point was simply this: Redux does not require users to follow FSA so we should also not.
Now I did here #1183 (comment)