Return multiple actions from useStoreActions?
See original GitHub issueSo while the naming of useStoreActions would imply you can return multiple actions from a single call, is that safe/performant to do?
For example:
const { attachPaymentMethod, submit } = useStoreActions(x => ({
attachPaymentMethod: x.attachPaymentMethod,
submit: x.submit
}))
I ask because it seems to be recommended that you return only a single value from useStoreState, so wandered if the same applies?
thx
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:25 (24 by maintainers)
Top Results From Across the Web
Dispatching Multiple Actions from NGRX Effects - Medium
In this example, I need to do 2 actions in a single effect but @Effect expects us to return a new action. How...
Read more >How to use the easy-peasy.useStoreActions function in ... - Snyk
To help you get started, we've selected a few easy-peasy. ... state.progress.continuous); const setProgress = useStoreActions(actions => actions.progress.
Read more >Primary API - Easy Peasy v5
Don't execute any side effects within your action. Creating a Store ... The useStoreActions hook ... You can return data out of a...
Read more >Actions | Pinia
It is possible to observe actions and their outcome with store.$onAction() . The callback passed to it is executed before the action itself....
Read more >Easy-Peasy State Management Using React Easy Peasy
removeNote); const toggleNote = useStoreActions(actions => actions.toggleNote); return ( <li className= ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

That is one way, but I think that being able to pass a custom equality function to
useStoreStateis far more flexible…If the equality function is not given, it uses the current strict equality check - maintaining the current functionility.
This obviously allows the user to perform any kind of comparison that they want without dictating too much.
If you add the ability to pass an equality function like this, it would be nice to also accept an options-hash. I think most uses of this (possibly 99.99%!) would be shallow-equal. Rather than require a separate utility import for this basic need, an ‘equality type’ could be accepted, something like:
A shallow-equal method is just a couple lines of code so would not bloat the library.
Shallow-equal is the standard comparison offered by React (props/state) and React-Redux (mapStateToProps), so this would replicate that. Anything more complex can be handled by a custom equalityFunction.