-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[@wordpress/notices
] Add a new action removeNotices
which allows bulk removal of notices
#39940
Conversation
08082b4
to
927fb58
Compare
Thank you for putting this together! Would you be able to add an example to the docblock? It does a long way in helping developers wanting to use this action. Here is an example for reference |
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.
Looks good, test well. E2E tests seem to be unrelated.
@ryanwelcher great idea, thanks. I've updated the PR to include an example. |
@nerrad this has been rebased and tested. On my end it works OK. |
|
…bulk removal of notices (WordPress#39940) * Add removeNotices action creator * Handle REMOVE_NOTICES in reducer * Add tests for reducer and actions * Move test to better position and add one for multiple contexts * Use .filter instead of reject * Add example component to doc block * Add changelog entry * Correct spacing on list item * Add correct changelog heading
What?
Adds a new action on the
core/notices
store that will remove several notices at once by supplying multiple IDs.removeNotices( [ 'some-id', 'some-other-id' ] )
Why?
To remove multiple notices, you'd need to make several calls to
removeNotice
this makes a slight performance improvement by only dispatching one action.An example use case is in WooCommerce Blocks where we need to remove several notices of a certain type.
Currently we loop through each notice and dispatch the
removeNotice
action for each of them. It would be more performant if we could dispatch a single action and achieve the same result.How?
Adds a new action creator and the action is handled in a new case in the reducer.
Testing Instructions
Test 2
error.