-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into workspace-folders-api
- Loading branch information
Showing
14 changed files
with
402 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (C) 2018 TypeFox and others. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
import * as ReactDOM from "react-dom"; | ||
import * as React from "react"; | ||
import { injectable } from "inversify"; | ||
import { DisposableCollection, Disposable } from "../../common"; | ||
import { BaseWidget, Message } from "./widget"; | ||
|
||
@injectable() | ||
export abstract class ReactWidget extends BaseWidget { | ||
|
||
protected readonly onRender = new DisposableCollection(); | ||
protected scrollOptions = { | ||
suppressScrollX: true | ||
}; | ||
|
||
constructor() { | ||
super(); | ||
this.toDispose.push(Disposable.create(() => { | ||
ReactDOM.unmountComponentAtNode(this.node); | ||
})); | ||
} | ||
|
||
protected onUpdateRequest(msg: Message): void { | ||
super.onUpdateRequest(msg); | ||
ReactDOM.render(<React.Fragment>{this.render()}</React.Fragment>, this.node, () => this.onRender.dispose()); | ||
} | ||
|
||
protected abstract render(): React.ReactNode; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.