2017-10-05 104 views
0

有誰知道如何添加終極版 - 堅持https://github.com/rt2zz/redux-persist 從入門工具包店:https://www.baqend.com/guide/starter-kits/react/使用終極版 - 堅持與Baqend反應,和/終極版入門

import { applyMiddleware, combineReducers } from 'redux' 

import { createStoreWithBaqend, baqendReducer } from 'redux-baqend' 
import middlewares from '../middleware' 
import reducers from '../reducers' 

import { db } from 'baqend' 

export default (initialState = {}) => { 
    const reducer = combineReducers({ 
    baqend: baqendReducer, 
    ...reducers 
    }) 
    const middleware = applyMiddleware(
    ...middlewares 
) 
    return createStoreWithBaqend(
    db.connect('remarkable-apple-XX', true), 
    reducer, 
    initialState, 
    middleware 
) 
} 

回答

0

我沒有這個尚未嘗試過自己,但來自redux-persist的文檔看起來就像添加了autoRehydrate並將創建的商店包裝在persistStore方法中。 createStoreWithBaqend方法與普通的createStore方法基本相同,但在商店中添加了一些baqend特定的東西。

我會嘗試這樣的:

export default (initialState = {}) => { 
    const reducer = combineReducers({ 
    baqend: baqendReducer, 
    ...reducers 
    }) 
    const middleware = applyMiddleware(
    ...middlewares 
) 
    const store = createStoreWithBaqend(
    db.connect('remarkable-apple-XX', true), 
    reducer, 
    initialState, 
    compose(
     middleware, 
     autoRehydrate() 
    ) 
) 
    return persistStore(store) 
} 

記得從Redux的庫中導入撰寫。希望這可以幫助。