import React from 'react'; import ls from './Section.less'; import Fa from './Fa'; export const TabContext = React.createContext(0); export class Section extends React.PureComponent { constructor({defaultOpen}) { super(); this.state = { closed: !defaultOpen }; } render() { const {label, nonClosable, children} = this.props; const closed = this.isClosed(); return { tabs =>
{label}
{!closed && children}
}
; } isClosed() { const {nonClosable} = this.props; if (nonClosable) return false; return this.state.closed; } tweakClose = () => { this.setState({closed: !this.isClosed()}); }; }