Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{ push } don`t work in actions #285

Open
mikilka opened this issue Feb 18, 2017 · 1 comment
Open

{ push } don`t work in actions #285

mikilka opened this issue Feb 18, 2017 · 1 comment

Comments

@mikilka
Copy link

mikilka commented Feb 18, 2017

Version

2.1.2

Steps to reproduce

Add push method to actions

export const actions = {};

actions.readStaff = (id) => {
    return (dispatch) => {
        dispatch(showLoading());
        staff.read(id)
            .then((response) => {
                const data = normalize(response, [staffSchema]);
                dispatch(creators.get('readStaff')(data));
            })
            .then(() => {
                dispatch(push('/staff'));
            })
            .then(() => {
                dispatch(hideLoading());
            });
    };

Init action in the component (I also dispatch actions in container for this component)

import React, { Component, PropTypes } from 'react';
import { push } from 'redux-router';
import { connect } from 'react-redux';

@connect((state) => ({}))
export default class Menu extends Component {
    static propTypes = {
        actions:    PropTypes.object.isRequired
    };

    static defaultProps = {
        actions:    {}
    };

    constructor (props) {
        super(props);
        this._toStaff =  ::this._toStaff;
    }

    _toStaff (event) {
        event.preventDefault();
        this.props.actions.readStaff();
    }

    render () {
        return (
            <section>
                <button onClick = { this._toStaff }>to staff</button>
            </section>
        );
    }
}

Expected Behavior

Push to a new page after the response.
If anybody know best solution for this, please contact me.

Actual Behavior

It dispatch push method with right route in the args, but do nothing.
image 2017-02-18 at 4 07 19 pm

@lbdremy
Copy link

lbdremy commented May 28, 2017

Any updates on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants