diff --git a/types/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx b/types/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx index 956df59f9c..904fd4f4d5 100644 --- a/types/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx +++ b/types/react-smooth-scrollbar/react-smooth-scrollbar-tests.tsx @@ -5,10 +5,12 @@ import * as SmoothScrollbar from "react-smooth-scrollbar"; ; class Test extends React.Component { - ref: SmoothScrollbar; + ref: SmoothScrollbar | null; componentDidMount() { - this.ref.scrollbar.scrollTo(0, 500); + if (this.ref) { + this.ref.scrollbar.scrollTo(0, 500); + } } render() { diff --git a/types/react-svg-pan-zoom/react-svg-pan-zoom-tests.tsx b/types/react-svg-pan-zoom/react-svg-pan-zoom-tests.tsx index a2d078d6d2..149867b0e4 100644 --- a/types/react-svg-pan-zoom/react-svg-pan-zoom-tests.tsx +++ b/types/react-svg-pan-zoom/react-svg-pan-zoom-tests.tsx @@ -8,21 +8,29 @@ import { } from 'react-svg-pan-zoom'; class Example1 extends React.Component<{}, {}> { - Viewer: ReactSVGPanZoom; + Viewer: ReactSVGPanZoom | null; constructor(props: Props) { super(props); } componentDidMount() { - this.Viewer.fitToViewer(); + if (this.Viewer) { + this.Viewer.fitToViewer(); + } } render() { return (
- - - + + +
diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 37abe824d7..0d9fd00d0e 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for React v15.0 // Project: http://facebook.github.io/react/ -// Definitions by: Asana , AssureSign , Microsoft , John Reilly , Benoit Benezech , Patricio Zavolinsky , Digiguru , Eric Anderson +// Definitions by: Asana , AssureSign , Microsoft , John Reilly , Benoit Benezech , Patricio Zavolinsky , Digiguru , Eric Anderson , Albert Kurniawan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -29,7 +29,7 @@ declare namespace React { type ComponentType

= ComponentClass

| StatelessComponent

; type Key = string | number; - type Ref = string | ((instance: T) => any); + type Ref = string | ((instance: T | null) => any); type ComponentState = {} | void; interface Attributes { @@ -447,7 +447,7 @@ declare namespace React { * `createElement` or a factory, use `ClassAttributes`: * * ```ts - * var b: Button; + * var b: Button | null; * var props: ButtonProps & ClassAttributes