forked from Gitlink/forgeplus-react
切换左侧目录,选择不同的文件时,文件详情没有更新
This commit is contained in:
parent
70edb73f6c
commit
6ee257231d
|
@ -31,6 +31,18 @@ class CoderRootFileDetail extends Component {
|
||||||
this.languages_total();
|
this.languages_total();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
componentDidUpdate=(prevProps)=>{
|
||||||
|
const { content } = this.props && this.props.detail;
|
||||||
|
const prevcontent = prevProps.detail && prevProps.detail.content;
|
||||||
|
if (content && prevcontent) {
|
||||||
|
if (prevcontent !== content){
|
||||||
|
this.setState({
|
||||||
|
description: content
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
languages_total = () => {
|
languages_total = () => {
|
||||||
const { detail } = this.props;
|
const { detail } = this.props;
|
||||||
const file_name = detail.path.split("/").pop().split(".").pop();
|
const file_name = detail.path.split("/").pop().split(".").pop();
|
||||||
|
@ -268,7 +280,7 @@ class CoderRootFileDetail extends Component {
|
||||||
{...this.state}
|
{...this.state}
|
||||||
language={language ? language : "javascript"}
|
language={language ? language : "javascript"}
|
||||||
filepath={`/${detail.path}`}
|
filepath={`/${detail.path}`}
|
||||||
content={detail.content}
|
content={description}
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
editorType="update"
|
editorType="update"
|
||||||
currentBranch={currentBranch}
|
currentBranch={currentBranch}
|
||||||
|
|
|
@ -12,6 +12,13 @@ class m_editor extends Component {
|
||||||
editorValue: this.props.content,
|
editorValue: this.props.content,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
componentDidUpdate=(prevProps)=>{
|
||||||
|
if(prevProps && this.props && this.props.content !== prevProps.content){
|
||||||
|
this.setState({
|
||||||
|
editorValue:this.props.content
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
changeEditor = (editorValue) => {
|
changeEditor = (editorValue) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
editorValue,
|
editorValue,
|
||||||
|
|
Loading…
Reference in New Issue