negomi / redux-burger-menu

A Redux reducer and higher-order component decorator for use with react-burger-menu
https://negomi.github.io/redux-burger-menu/
MIT License
118 stars 19 forks source link

closing the menu won't fire redux action #16

Open minotaurrr opened 6 years ago

minotaurrr commented 6 years ago

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?

minotaurrr commented 6 years ago

7 This workaround worked for me