import React from 'react';
import Menu from './Menu';
import { connect } from 'react-redux';

const mapStateToProps = (state) => {
    return {
        menu: Array.isArray(state.menu) ? state.menu : [],
        layers: Array.isArray(state.layers) ? state.layers : []
    };
};

const mapDispatchToProps = (dispatch) => {
    return {
        onLayerClick: (id) => {
            dispatch({
                type: 'TOGGLE_LAYER',
                id
            })
        }
    };
};

const MenuContainer = connect(
    mapStateToProps,
    mapDispatchToProps
)(Menu)

export default MenuContainer;

import React from 'react';
import Menu from './Menu';
import { connect } from 'react-redux';

const mapStateToProps = (state) => {
    return {
        menuItems: Array.isArray(state.menuItems) ? state.menuItems : [],
        layers: Array.isArray(state.layers) ? state.layers : []
    };
};

const mapDispatchToProps = (dispatch) => {
    return {
        onLayerClick: (id) => {
            dispatch({
                type: 'TOGGLE_LAYER',
                id
            })
        },
        onMenuClick: (id) => {
            dispatch({
                type: 'TOGGLE_MENU',
                id
            })
        }
    };
};

const MenuContainer = connect(
    mapStateToProps,
    mapDispatchToProps
)(Menu)

export default MenuContainer;

Refactor stage menu to stage menuItems
Refactor stage menu to stage menuItems
