Update block scaffolding to use the withNotices HOC#14895
Conversation
|
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: April 7, 2020. |
| const setErrorNotice = () => { | ||
| noticeOperations.removeAllNotices(); | ||
| noticeOperations.createErrorNotice( __( 'Put error message here.', 'jetpack' ) ); | ||
| }; |
There was a problem hiding this comment.
Part of me wonders if we shouldn't extract this into a shared function available to all blocks? Ideally, that function could also handle all kinds of notices, not just erors. Something like this:
export function displayNotice( message, noticeOperations, type = 'error' ) {
noticeOperations.removeAllNotices();
noticeOperations.createNotice( { status: type, content: message } );
}There was a problem hiding this comment.
That might be worth trying in some blocks, but I'd rather we only move stuff into the scaffolding when we've already had success with it in other blocks.
There was a problem hiding this comment.
You're right. I suggested we give that a try in #14884 (comment)
Until then, we should be able to merge your PR and revisit once we have some blocks using it.
Co-Authored-By: Jeremy Herve <jeremy@jeremy.hu>
In of #14884 we realised we were doing notices wrongly. We should update the block scaffolding to do it the right way.
Changes proposed in this Pull Request:
withNoticesHOCIs this a new feature or does it add/remove features to an existing part of Jetpack?
Testing instructions:
Proposed changelog entry for your changes: