1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-12 09:36:32 +02:00

change componentWillUpdate to componentDidUpdate

This commit is contained in:
Kushagra Gour
2019-03-01 16:18:11 +05:30
parent 0a65207a7f
commit 30afda75f3
2 changed files with 8 additions and 3 deletions

View File

@ -24,14 +24,15 @@ class LogRow extends Component {
} }
export class Console extends PureComponent { export class Console extends PureComponent {
componentWillUpdate(nextProps) { componentDidUpdate(previousProps) {
if (nextProps.logs != this.props.logs) { if (this.props.logs !== previousProps.logs) {
// Scroll down after new log dom is inserted // Scroll down after new log dom is inserted
setTimeout(() => { setTimeout(() => {
this.logContainerEl.scrollTop = this.logContainerEl.scrollHeight; this.logContainerEl.scrollTop = this.logContainerEl.scrollHeight;
}, 1); }, 1);
} }
} }
render() { render() {
const { const {
logs, logs,
@ -79,7 +80,9 @@ export class Console extends PureComponent {
this.logContainerEl = el; this.logContainerEl = el;
}} }}
> >
{logs.map(log => <LogRow data={log} />)} {logs.map(log => (
<LogRow data={log} />
))}
</ul> </ul>
</div> </div>
<div <div

View File

@ -72,6 +72,8 @@ export default class ContentWrapFiles extends Component {
); );
} }
componentWillUpdate(nextProps) { componentWillUpdate(nextProps) {
// TODO: REMOVE AS THIS LIFECYCLE HOOK IS DEPRECATED
// If we get a new Item, clear file buffers and currently selected file. // If we get a new Item, clear file buffers and currently selected file.
if ( if (
this.props.currentItem.createdOn !== nextProps.currentItem.createdOn || this.props.currentItem.createdOn !== nextProps.currentItem.createdOn ||