使用 React.createClass 时,Typescript 抱怨“JSX.IntrinsicElements"类型上不存在属性? [英] Typescript complains Property does not exist on type 'JSX.IntrinsicElements' when using React.createClass?
本文介绍了使用 React.createClass 时,Typescript 抱怨“JSX.IntrinsicElements"类型上不存在属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 typescript 编写 redux 应用程序.
I am using typescript to write redux application.
var item = React.createClass({
render: function() {
return (<div>hello world</div>)
}
});
export default class ItemList extends Component<any, any> {
render() {
return (<item />)
}
}
然后打字稿抱怨这个:
Property 'item' does not exist on type 'JSX.IntrinsicElements'.
推荐答案
你的组件必须以大写字母 I
开头,而不是小写字母 i
否则 TypeScript 会大喊大叫.将 item
更改为 Item
应该可以修复它:
Your component must start with a capital letter I
instead of small letter i
otherwise TypeScript would yell. Changing item
to Item
should fix it:
var Item = React.createClass({
render: function() {
return (<div>hello world</div>)
}
});
export default class ItemList extends Component<any, any> {
render() {
return (<Item />)
}
}
这篇关于使用 React.createClass 时,Typescript 抱怨“JSX.IntrinsicElements"类型上不存在属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文