-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.js
37 lines (24 loc) · 949 Bytes
/
client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const merely = require('merely');
import { createStore } from 'redux'
import { Provider } from 'react-redux'
merely.plugin('merely-react-redux', (options, isDev) => {
let devStore
merely.filter('wrapRootComponent', (root, ctx) => {
let missingExports = [];
if(!ctx.app.getReducers) {
missingExports.push('getReducers');
}
if(!ctx.app.getDefaultState) {
missingExports.push('getDefaultState');
}
if(missingExports.length) {
throw new Error("You're using the 'merely-react-redux' plugin for Merely, however you must also export some extra functions from your main.js file! You're missing "+missingExports.join(', '));
}
// if(isDev) {
const store = (isDev && devStore) || createStore(ctx.app.getReducers(), ctx.app.getDefaultState());
if(isDev) devStore = store
window.store = store;
return <Provider store={store}>{root}</Provider>
// }
});
});