diff --git a/packages/edit-widgets/src/store/private-selectors.js b/packages/edit-widgets/src/store/private-selectors.js index 29911091622fbb..fca6aa5ddb759c 100644 --- a/packages/edit-widgets/src/store/private-selectors.js +++ b/packages/edit-widgets/src/store/private-selectors.js @@ -1,16 +1,3 @@ -/** - * External dependencies - */ -import createSelector from 'rememo'; - -/** - * WordPress dependencies - */ -import { createRef } from '@wordpress/element'; - -export const getListViewToggleRef = createSelector( - () => { - return createRef(); - }, - () => [] -); +export function getListViewToggleRef( state ) { + return state.listViewToggleRef; +} diff --git a/packages/edit-widgets/src/store/reducer.js b/packages/edit-widgets/src/store/reducer.js index ff942b955edcdc..64bd6b4e0400e7 100644 --- a/packages/edit-widgets/src/store/reducer.js +++ b/packages/edit-widgets/src/store/reducer.js @@ -68,6 +68,17 @@ export function listViewPanel( state = false, action ) { return state; } +/** + * This reducer does nothing aside initializing a ref to the list view toggle. + * We will have a unique ref per "editor" instance. + * + * @param {Object} state + * @return {Object} Reference to the list view toggle button. + */ +export function listViewToggleRef( state = { current: null } ) { + return state; +} + export default combineReducers( { blockInserterPanel, listViewPanel, diff --git a/packages/editor/src/store/private-selectors.js b/packages/editor/src/store/private-selectors.js index b05dcae93c9472..e276859f884038 100644 --- a/packages/editor/src/store/private-selectors.js +++ b/packages/editor/src/store/private-selectors.js @@ -1,14 +1,8 @@ -/** - * External dependencies - */ -import createSelector from 'rememo'; - /** * WordPress dependencies */ import { store as blockEditorStore } from '@wordpress/block-editor'; import { createRegistrySelector } from '@wordpress/data'; -import { createRef } from '@wordpress/element'; /** * Internal dependencies @@ -52,9 +46,6 @@ export const getInsertionPoint = createRegistrySelector( } ); -export const getListViewToggleRef = createSelector( - () => { - return createRef(); - }, - () => [] -); +export function getListViewToggleRef( state ) { + return state.listViewToggleRef; +} diff --git a/packages/editor/src/store/reducer.js b/packages/editor/src/store/reducer.js index a2d24789cd33f5..978a5c8697410a 100644 --- a/packages/editor/src/store/reducer.js +++ b/packages/editor/src/store/reducer.js @@ -349,6 +349,17 @@ export function listViewPanel( state = false, action ) { return state; } +/** + * This reducer does nothing aside initializing a ref to the list view toggle. + * We will have a unique ref per "editor" instance. + * + * @param {Object} state + * @return {Object} Reference to the list view toggle button. + */ +export function listViewToggleRef( state = { current: null } ) { + return state; +} + export default combineReducers( { postId, postType, @@ -365,4 +376,5 @@ export default combineReducers( { removedPanels, blockInserterPanel, listViewPanel, + listViewToggleRef, } );