Skip to content

Commit 8b4561d

Browse files
committed
Add pass the instance state in the function
1 parent 2c11ee5 commit 8b4561d

9 files changed

Lines changed: 175 additions & 632 deletions

File tree

src/framework/index.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createBrowserHistory } from 'history';
44
import { configureStore } from './store/store';
55
import { clearActionsCache } from './store/actions';
66
import { createActionSequences } from './store/sequences';
7+
import { createInitialState } from './store/state';
78

89
import PageRouter from './components/PageRouter';
910
import StartWrapper from './components/StartWrapper';
@@ -18,12 +19,10 @@ if (process.env.NODE_ENV !== 'production') {
1819
PageComposer = require('./components/PageComposer/PageComposer').default;
1920
}
2021

21-
let store;
22-
let history;
23-
24-
export const initStore = (name, version, initialState = {}) => {
25-
history = createBrowserHistory();
26-
store = configureStore(initialState, { history }, { name, version });
22+
const initStore = (pages, name, version) => {
23+
const initialState = createInitialState(pages);
24+
const history = createBrowserHistory();
25+
const store = configureStore(initialState, { history }, { name, version });
2726

2827
if (process.env.NODE_ENV !== 'production') {
2928
window.__sendFrameworkMessage = (message) => {
@@ -82,12 +81,7 @@ class Application extends React.Component {
8281
};
8382

8483
render () {
85-
if (!store) {
86-
return (
87-
<WarningComponent message="Redux store is not initialized." />
88-
);
89-
}
90-
const { schema, userComponents, userFunctions } = this.props;
84+
const { schema, userComponents, userFunctions, name, version } = this.props;
9185
if (process.env.NODE_ENV !== 'production') {
9286
const href = window.location.href;
9387
if (href.indexOf('/webcodesk__component_view') > 0) {
@@ -100,8 +94,15 @@ class Application extends React.Component {
10094
)
10195
}
10296
}
103-
clearActionsCache();
10497
const { routes, pages, flows } = schema;
98+
const {store, history } = initStore(pages, name, version);
99+
if (!store) {
100+
return (
101+
<WarningComponent message="Redux store is not initialized." />
102+
);
103+
}
104+
window.__applicationBrowserHistory = history;
105+
clearActionsCache();
105106
const { actionSequences, targetProperties } = createActionSequences(flows, userFunctions);
106107
// store action sequences and components properties in case we have to send them for debug
107108
this.actionSequences = actionSequences;

src/framework/store/__tests__/__snapshots__/actions.test.js.snap

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)