Add a Component interface that merges w/the class

The Component interface extends ComponentLifecycle. ComponentLifecycle
goes back to being an interface.

Also fix some lint in react-virtualized
This commit is contained in:
Nathan Shively-Sanders
2017-05-24 09:15:22 -07:00
parent 9853ed4e21
commit 43d74e2dfe
2 changed files with 5 additions and 12 deletions
@@ -405,11 +405,7 @@ export class ColumnSizerExample extends PureComponent<any, any> {
_noColumnMaxWidthChange(event) {
let columnMaxWidth = parseInt(event.target.value, 10)
if (isNaN(columnMaxWidth)) {
columnMaxWidth = undefined
} else {
columnMaxWidth = Math.min(1000, columnMaxWidth)
}
columnMaxWidth = isNaN(columnMaxWidth) ? undefined : Math.min(1000, columnMaxWidth)
this.setState({ columnMaxWidth })
}
@@ -417,11 +413,7 @@ export class ColumnSizerExample extends PureComponent<any, any> {
_noColumnMinWidthChange(event) {
let columnMinWidth = parseInt(event.target.value, 10)
if (isNaN(columnMinWidth)) {
columnMinWidth = undefined
} else {
columnMinWidth = Math.max(1, columnMinWidth)
}
columnMinWidth = isNaN(columnMinWidth) ? undefined : Math.max(1, columnMinWidth)
this.setState({ columnMinWidth })
}
+3 -2
View File
@@ -178,7 +178,8 @@ declare namespace React {
type ReactInstance = Component<any, any> | Element;
// Base component for plain JS classes
class Component<P, S> extends ComponentLifecycle<P, S> {
interface Component<P, S> extends ComponentLifecycle<P, S> { }
class Component<P, S> {
constructor(props?: P, context?: any);
setState<K extends keyof S>(f: (prevState: S, props: P) => Pick<S, K>, callback?: () => any): void;
setState<K extends keyof S>(state: Pick<S, K>, callback?: () => any): void;
@@ -251,7 +252,7 @@ declare namespace React {
// Component Specs and Lifecycle
// ----------------------------------------------------------------------
class ComponentLifecycle<P, S> {
interface ComponentLifecycle<P, S> {
componentWillMount?(): void;
componentDidMount?(): void;
componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void;