Browse Source

adjust using componentWillMount

yusuketk 7 years ago
parent
commit
4b9da4bb25

+ 3 - 5
src/client/js/components/Page/EditTagModal.jsx

@@ -22,13 +22,11 @@ export default class EditTagModal extends React.Component {
     this.handleShowModal = this.handleShowModal.bind(this);
     this.handleCloseModal = this.handleCloseModal.bind(this);
     this.handleSubmit = this.handleSubmit.bind(this);
-    this.getCurrentTags = this.getCurrentTags.bind(this);
-
-    this.getCurrentTags(this.props.pageId);
   }
 
-  async getCurrentTags(pageId) {
+  async componentWillMount() {
     // set pageTag on button
+    const pageId = this.props.pageId;
     if (pageId) {
       const res = await this.props.crowi.apiGet('/tags.get', { pageId });
       this.setState({ currentPageTags: res.tags });
@@ -82,7 +80,7 @@ export default class EditTagModal extends React.Component {
           placement="bottom"
           overlay={(
             <Tooltip id="tooltip-bottom">
-              {this.state.currentPageTags.join()}
+              {this.state.currentPageTags.length !== 0 ? this.state.currentPageTags : 'ページタグ未設定'}
             </Tooltip>
           )}
         >

+ 1 - 5
src/client/js/components/PageTagForm.jsx

@@ -19,15 +19,11 @@ export default class PageTagForm extends React.Component {
     this.state = {
       resultTags: [],
       isLoading: false,
-      selected: [],
+      selected: this.props.currentPageTags,
     };
     this.crowi = this.props.crowi;
   }
 
-  componentWillMount() {
-    this.setState({ selected: this.props.currentPageTags });
-  }
-
   render() {
     return (
       <div className="tag-typeahead">