Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property 'render' does not exist on type 'typeof __React'

When compiling script

/// <reference path="./typings/react/react.d.ts" />
import React = __React;

var content = <div>Hello, world!</div>;

React.render(content, document.getElementById('output'));

I get an error

$ tsc --jsx react app.tsx app.tsx(6,7): error TS2339: Property 'render' does not exist on type 'typeof __React'.

Is there any way to fix it? Thanks

like image 209
fpawel Avatar asked Nov 29 '15 07:11

fpawel


1 Answers

import React = __React;

Please use import React = require('react') ... but this is not the source of your error

React.render(content, document.getElementById('output'));

Please use ReactDOM.render( instead of React.render. Get react-dom as import ReactDOM = require('react-dom'). This is needed with react 0.14.

Alternatively get the old definitions for React.

like image 100
basarat Avatar answered Nov 05 '22 03:11

basarat