简体   繁体   English

类型'typeof __React'上不存在属性'render'

[英]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 谢谢

import React = __React;

Please use import React = require('react') ... but this is not the source of your error 请使用import React = require('react') ...但这不是您错误的来源

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 . 请使用ReactDOM.render(而不是React.render 。获取react-dom作为import ReactDOM = require('react-dom') 。这需要反应0.14

Alternatively get the old definitions for React . 或者,获取React旧定义

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 属性&#39;findDOMNode&#39;在&#39;typeof React&#39;类型上不存在 - Property 'findDOMNode' does not exist on type 'typeof React' React中的'Window&typeof globalThis'类型上不存在'属性'ethereum''错误 - `Property 'ethereum' does not exist on type 'Window & typeof globalThis'` error in React 属性“ typeof CommonStore”类型不存在。 mobx反应的 - Property does not exist on type 'typeof CommonStore'. mobx-react 在TSX文件中:属性&#39;createRef&#39;在类型&#39;typeof React&#39;上不存在 - In TSX file : Property 'createRef' does not exist on type 'typeof React' TSLINT 错误:属性“Component”在类型“typeof React”上不存在 - TSLINT Error: Property 'Component' does not exist on type 'typeof React' 类型“typeof client”上不存在属性“calendar” - Property 'calendar' does not exist on type 'typeof client' 类型“typeof TextInput”上不存在属性“propTypes” - Property 'propTypes' does not exist on type 'typeof TextInput' 类型 Window 和 typeof globalThis 上不存在属性 - Property does not exist on type Window & typeof globalThis 类型&#39;typeof FactoryMethod上不存在属性&#39;propTypes&#39; - Property 'propTypes' does not exist on type 'typeof FactoryMethod 类型“ typeof window”上不存在属性“ location” - Property 'location' does not exist on type 'typeof window'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM