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();
|
||||
};
|
||||
|
||||
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 = () => {
|
||||
const { detail } = this.props;
|
||||
const file_name = detail.path.split("/").pop().split(".").pop();
|
||||
|
@ -268,7 +280,7 @@ class CoderRootFileDetail extends Component {
|
|||
{...this.state}
|
||||
language={language ? language : "javascript"}
|
||||
filepath={`/${detail.path}`}
|
||||
content={detail.content}
|
||||
content={description}
|
||||
readOnly={readOnly}
|
||||
editorType="update"
|
||||
currentBranch={currentBranch}
|
||||
|
|
|
@ -12,6 +12,13 @@ class m_editor extends Component {
|
|||
editorValue: this.props.content,
|
||||
};
|
||||
}
|
||||
componentDidUpdate=(prevProps)=>{
|
||||
if(prevProps && this.props && this.props.content !== prevProps.content){
|
||||
this.setState({
|
||||
editorValue:this.props.content
|
||||
})
|
||||
}
|
||||
}
|
||||
changeEditor = (editorValue) => {
|
||||
this.setState({
|
||||
editorValue,
|
||||
|
|
Loading…
Reference in New Issue