import React from 'react'; import PropTypes from 'prop-types'; import CommentEditor from './CommentEditor'; export default class CommentEditorLazyRenderer extends React.Component { constructor(props) { super(props); this.state = { isEditorShown: false, isLayoutTypeGrowi: false, }; this.showCommentFormBtnClickHandler = this.showCommentFormBtnClickHandler.bind(this); } componentWillMount() { this.init(); } init() { const layoutType = this.props.crowi.getConfig().layoutType; this.setState({ isLayoutTypeGrowi: layoutType === 'crowi-plus' || layoutType === 'growi' }); } showCommentFormBtnClickHandler() { this.setState({ isEditorShown: true }); } render() { return ( { !this.state.isEditorShown && ( ) } { this.state.isEditorShown && } ); } } CommentEditorLazyRenderer.propTypes = { crowi: PropTypes.object.isRequired, crowiOriginRenderer: PropTypes.object.isRequired, editorOptions: PropTypes.object, slackChannels: PropTypes.string, };