清除Redux撤消历史记录

时间:2016-12-14 17:39:43

标签: reactjs redux

我们如何清除redux历史?我已经完成了撤消和重做以完美地工作,但出于某些原因,当我以相同的格式清除历史记录时(我也尝试过initTypes,它没有工作。< / p>

我的Reducer with undoable:

    const allReducers = combineReducers({
    activeUser: activeUser,
    activeBrochure: undoable(activeBrochure, {
        limit: 20,
        undoType: "BROCHURE_UNDO", // define a custom action type for this undo action
        redoType: "BROCHURE_REDO", // define a custom action type for this redo action
        clearHistoryType: "CLEAR_BROCHURE_HISTORY"  // [beta only] define custom action type for this clearHistory action
    }),
});

我的行动:

export const rerender = () => { return { type: "RERENDER_BROCHURE", payload: null } }
export const createNewBrochure = () => { return { type: "CREATE_NEW_BROCHURE", payload: null }; }
export const clearBrochureHistory = () => { 
    console.log("Action: Clear Brochure History!");
    return { type: "CLEAR_BROCHURE_HISTORY", payload: ActionCreators.clearHistory }; }
export const brochureUndo = () => { return { type: "BROCHURE_UNDO", payload: null } }
export const brochureRedo = () => { return { type: "BROCHURE_REDO", payload: null } }

组件接线:

    function mapStateToProps(state) {
    return {
        activeUser: state.activeUser,
        activeBrochure: state.activeBrochure.present,
        brochureHistory: state.activeBrochure.past
    }
}
        function matchDispatchToProps(dispatch) {
    return bindActionCreators({
        selectUser: Action.selectUser,
        createNewBrochure: Action.createNewBrochure,
        clearBrochureHistory: Action.clearBrochureHistory,
        selectBrochure: Action.selectBrochure,
        deleteBodyPage: Action.deleteBodyPage,
        brochureUndo: Action.brochureUndo,
        brochureRedo: Action.brochureRedo
    },
        dispatch);
}

export default connect(mapStateToProps, matchDispatchToProps)(NavigationBar)

我的组件JSX:

{

        //CLICK YES FUNCTION
        this.setState(update(this.state, { askNewBrochure: { $set: false } }));
        if (window.location.href.indexOf("brochureBuilder") < 0) {
            hashHistory.push("/brochureBuilder");
        }


        this.props.clearBrochureHistory();

0 个答案:

没有答案