import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import * as actions from '../../store/actions/actions'; import { TabContent, TabPane, Nav, NavItem, NavLink } from 'reactstrap'; class Offsidebar extends Component { state = { activeTab: 'settings', offsidebarReady: false } componentDidMount() { // When mounted display the offsidebar window.requestAnimationFrame(() => this.setState({ offsidebarReady: true })); } toggle = tab => { if (this.state.activeTab !== tab) { this.setState({ activeTab: tab }); } } handleSettingCheckbox = event => { this.props.actions.changeSetting(event.target.name, event.target.checked); } handleThemeRadio = event => { this.props.actions.changeTheme(event.target.value); } render() { return ( this.state.offsidebarReady && ); } } Offsidebar.propTypes = { actions: PropTypes.object, settings: PropTypes.object, theme: PropTypes.object }; const mapStateToProps = state => ({ settings: state.settings, theme: state.theme }) const mapDispatchToProps = dispatch => ({ actions: bindActionCreators(actions, dispatch) }) export default connect( mapStateToProps, mapDispatchToProps )(Offsidebar);