diff --git a/packages/edit-post/src/components/text-editor/index.js b/packages/edit-post/src/components/text-editor/index.js index 47f5d1107d76e..9c9b3c29e9948 100644 --- a/packages/edit-post/src/components/text-editor/index.js +++ b/packages/edit-post/src/components/text-editor/index.js @@ -8,30 +8,34 @@ import { store as editorStore, } from '@wordpress/editor'; import { Button } from '@wordpress/components'; -import { withDispatch, withSelect } from '@wordpress/data'; +import { useDispatch, useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { displayShortcut } from '@wordpress/keycodes'; -import { compose } from '@wordpress/compose'; /** * Internal dependencies */ import { store as editPostStore } from '../../store'; -function TextEditor( { onExit, isRichEditingEnabled } ) { +export default function TextEditor() { + const isRichEditingEnabled = useSelect( ( select ) => { + return select( editorStore ).getEditorSettings().richEditingEnabled; + }, [] ); + const { switchEditorMode } = useDispatch( editPostStore ); + return (
+ { isRichEditingEnabled && (

{ __( 'Editing code' ) }

-
) }
@@ -41,17 +45,3 @@ function TextEditor( { onExit, isRichEditingEnabled } ) {
); } - -export default compose( - withSelect( ( select ) => ( { - isRichEditingEnabled: select( editorStore ).getEditorSettings() - .richEditingEnabled, - } ) ), - withDispatch( ( dispatch ) => { - return { - onExit() { - dispatch( editPostStore ).switchEditorMode( 'visual' ); - }, - }; - } ) -)( TextEditor );