Refactor default state out of reducer

[MAILPOET-2450]
This commit is contained in:
Rostislav Wolny
2019-10-24 14:12:58 +02:00
committed by Jack Kitterhing
parent a94cf7e162
commit 63cde2e630
2 changed files with 7 additions and 7 deletions

View File

@ -1,10 +1,14 @@
import { registerStore } from '@wordpress/data'; import { registerStore } from '@wordpress/data';
import actions from './actions.jsx'; import actions from './actions.jsx';
import reducer from './reducer.jsx'; import createReducer from './reducer.jsx';
import selectors from './selectors.jsx'; import selectors from './selectors.jsx';
const defaultState = {
sidebarOpened: true,
};
const config = { const config = {
reducer, reducer: createReducer(defaultState),
actions, actions,
selectors, selectors,
controls: {}, controls: {},

View File

@ -1,8 +1,4 @@
const DEFAULT_STATE = { export default (defaultState) => (state = defaultState, action) => {
sidebarOpened: true,
};
export default (state = DEFAULT_STATE, action) => {
switch (action.type) { switch (action.type) {
case 'TOGGLE_SIDEBAR': case 'TOGGLE_SIDEBAR':
return { return {