Skip to content

Commit

Permalink
MediaReplaceFlow: Avoid React warning when selecting media (#34618)
Browse files Browse the repository at this point in the history
* MediaReplaceFlow: Avoid React warning when selecting media
* Add inline comment
  • Loading branch information
Mamaduka authored Sep 17, 2021
1 parent 4f3d93e commit d4674c7
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ const MediaReplaceFlow = ( {
};

const selectMedia = ( media ) => {
onSelect( media );
setMediaURLValue( media.url );
// Calling `onSelect` after the state update since it might unmount the component.
onSelect( media );
speak( __( 'The media file has been replaced' ) );
removeNotice( errorNoticeID );
};
Expand Down

0 comments on commit d4674c7

Please sign in to comment.