import React, { Component } from 'react'; import { Transition } from 'react-transition-group'; import './widget.scss'; class Widget extends Component { state = { opened: false, showDock: true, } handleToggleOpen = () => { this.setState((prev) => { let { showDock } = prev; if (!prev.opened) { showDock = false; } return { showDock, opened: !prev.opened, }; }); } handleWidgetExit = () => { this.setState({ showDock: true, }); } renderBody = () => { const { showDock } = this.state; if (!showDock) return ''; return ( ); } render() { const { opened } = this.state; const body = this.renderBody(); return (
{status => (
Header
Body
Footer
)}
{body}
); } } export default Widget;