/** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the CC-BY-4.0 license found * in the LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; import React, {Component} from 'react'; import Flex from 'components/Flex'; import Section from './Section'; import {media} from 'theme'; class Sidebar extends Component { constructor(props, context) { super(props, context); this.state = { activeSection: props.defaultActiveSection, }; } render() { const {closeParentMenu, createLink, location, sectionList} = this.props; const {activeSection} = this.state; return ( {sectionList.map((section, index) => (
this._toggleSection(section)} section={section} /> ))} ); } _toggleSection(section) { this.setState(state => ({ activeSection: state.activeSection === section ? null : section, })); } } export default Sidebar;