import React from 'react'; import PropTypes from 'prop-types'; import { exportXLS } from './excel-export'; class ExportButton extends React.PureComponent { constructor (props) { super(props); this.handleExport = this.handleExport.bind(this); } handleExport () { const { excelExport, general } = this.props; const { title, subtitle, footnote } = general; if (excelExport) { exportXLS(title, subtitle, footnote); } } render () { const { excelExport } = this.props; return excelExport === true && ( ); } } ExportButton.defaultProps = { excelExport: false }; ExportButton.propTypes = { excelExport: PropTypes.bool, general: PropTypes.shape({}).isRequired }; export default ExportButton;