相关疑难解决方法(0)

使用React.createClass时,类型'抱怨'在'JSX.IntrinsicElements'类型中不存在?

我正在使用typescript来编写redux应用程序.

var item = React.createClass({
  render: function() {
    return (<div>hello world</div>)
  }
});

export default class ItemList extends Component<any, any> {
    render() {
        return (<item />)
    }
}
Run Code Online (Sandbox Code Playgroud)

然后打字稿抱怨这个:

Property 'item' does not exist on type 'JSX.IntrinsicElements'.
Run Code Online (Sandbox Code Playgroud)

typescript reactjs redux

17
推荐指数
8
解决办法
1万
查看次数

使用本机 Web 组件时,Typescript 错误“类型 'JSX.IntrinsicElements' 上不存在属性”

我正在处理一个使用 React 和 Typescript 的项目,但我想开始在我的项目中使用原生 Web 组件来逐步淘汰我的一些 React 组件。

当我尝试在我的person-info某些 JSX 中包含使用组件时出现此错误。

Property does not exist on type 'JSX.IntrinsicElements'
Run Code Online (Sandbox Code Playgroud)

我查看了其他一些有这些问题的问题,但它们似乎都与本机 Web 组件没有任何关系。

当我在我的项目中使用我的 web 组件时,如何让 Typescript 和 React 很好地发挥作用?

人物信息.mjs

const css = `
  <style>
    :host([hidden]) { display: none; }
    :host {
      align-items: center;
      display: grid;
      font-weight: normal;
      grid-gap: var(--spacing-size-a) var(--spacing-size-a);
      grid-template-areas:
        'picture heading'
        'picture sub-heading';
      grid-template-columns: auto 1fr;
      justify-items: start;
    }
    div {
      grid-area: picture;
    }
    h1, h2 {
      margin: 0;
      padding: 0;
    }
    h1 {
      align-self: …
Run Code Online (Sandbox Code Playgroud)

javascript web-component typescript reactjs native-web-component

6
推荐指数
1
解决办法
7232
查看次数