negomi / redux-burger-menu

A Redux reducer and higher-order component decorator for use with react-burger-menu

Home Page:https://negomi.github.io/redux-burger-menu/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

closing the menu won't fire redux action

minotaurrr opened this issue · comments

commented

Hi,

I noticed no redux action is fired when I close the menu.

class SideMenu extends React.Component {
    componentDidMount() {}
    render() {
        return (
            <Menu
                customBurgerIcon={false}
                isOpen={this.props.isOpen}
                pageWrapId={'page-wrap'}
                outerContainerId={'outer-container'}
            >
                <span>test</span>
            </Menu>
        );
    }
}

const mapStateToProps = state => ({
    isOpen: state.burgerMenu.isOpen,
});

export default connect(mapStateToProps)(reduxBurgerMenu(SideMenu));

I have another component that has a button which fires the toggleMenu action like so:

class AnotherClass..... {
    render() {
        return(
            ....<Button onClick={() => toggleMenu(isOpen)}>Open Menu</Button>
        )
    }
}

I'm using the following

"react": "^16.6.0",
"react-redux": "^5.1.0",
"redux": "^4.0.1",
"redux-burger-menu": "^0.2.8",
"react-burger-menu": "^2.5.4",

The initial state for isOpen is false so the button works only the first time.
When the menu is closed isOpen stays true since no action is fired so the button doesn't work anymore.

Anyone experienced a similar issue?

commented

#7 This workaround worked for me