From 82e42f3d53015af41a3224795b929b46f72a05a1 Mon Sep 17 00:00:00 2001 From: Hraban Luyat Date: Sun, 9 Nov 2014 04:12:34 +0100 Subject: [PATCH] React.render() return value incorrect React.render does not return an element but a component. It's the `this` from the render callback: > Instances of a React Component are created internally in React when rendering. These instances are reused in subsequent renders, and can be accessed in your component methods as this. The only way to get a handle to a React Component instance outside of React is by storing the return value of React.render. Inside other Components, you may use refs to achieve the same result. http://facebook.github.io/react/docs/component-api.html This particular pull request is probably not perfect (e.g. I don't know what to pass as the type parameter for state so I just set it to `void`). It does scratch my particular itch, though; calling `.setProps(..)` on the return value of `React.render(...)` is now possible. Sorry if I misunderstood. By no means a react expert. Nor typescript, for that matter. Cheers --- react/react.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react/react.d.ts b/react/react.d.ts index 40522920fc..b8d627eea3 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -18,7 +18,7 @@ declare module React { export function createElement(type: string, props: SvgAttributes, ...children: any[]): ReactSVGElement; - export function render

(component: ReactComponentElement

, container: Element, callback?: () => void): ReactComponentElement

; + export function render

(component: ReactComponentElement

, container: Element, callback?: () => void): Component; export function render(component: ReactHTMLElement, container: Element, callback?: () => void): ReactHTMLElement; @@ -604,4 +604,4 @@ declare module React { text: SvgElement; tspan: SvgElement; }; -} \ No newline at end of file +}