IntrinsicElements类型不存在属性

IntrinsicElements类型不存在属性

本文介绍了JSX错误:'JSX.IntrinsicElements类型不存在属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Container转换为.jsx文件,但现在在render方法中,我的HTML元素出现以下错误:

I converted my Container into a .jsx file, but now I'm getting the following errors on my HTML elements in the render method:

"JSX.IntrinsicElements.h1"类型上不存在该属性

Property does not exist on type 'JSX.IntrinsicElements.h1


package.json


package.json

{
  "name": "moonholdings.io",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "build-css": "node-sass-chokidar src/ -o src/ --source-map",
    "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive --source-map",
    "start": "react-scripts-ts start",
    "build": "react-scripts-ts build",
    "test": "react-scripts-ts test --env=jsdom",
    "eject": "react-scripts-ts eject"
  },
  "dependencies": {
    "node-sass-chokidar": "^1.3.3",
    "react": "^16.5.1",
    "react-dom": "^16.5.1",
    "react-redux": "^5.0.7",
    "react-router-dom": "^4.3.1",
    "react-scripts-ts": "2.17.0",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "@types/jest": "^23.3.2",
    "@types/react": "^16.4.14",
    "@types/react-dom": "^16.0.5",
    "@types/react-redux": "^6.0.9",
    "@types/react-router": "^4.0.25",
    "@types/react-router-dom": "^4.2.6",
    "@types/react-router-redux": "^5.0.14",
    "@types/redux": "^3.6.31",
    "ramda": "^0.25.0",
    "typescript": "^3.0.3"
  }
}

loginContainer.js

loginContainer.js

    import * as React from 'react';
import { connect } from 'react-redux';

// Actions
// import { addCoins } from 'actions/coins';

interface IProps {
  loginActions: any
}

interface IState {
  email: string;
  password: string;
}

class LoginContainer extends React.Component<IProps, IState> {

  public state: IState = {
    email: '',
    password: ''
  };

  public render() {
    return (
      <div id="login-container">
        <h1>Login</h1>
      </div>
    );
  }
}

// const mapDispatchToProps = dispatch => ({
//   addCoins: (...args) => dispatch(addCoins(...args))
// });

export const LoginContainerJest = LoginContainer;

export default connect(null, null)(LoginContainer);

我有rm -R node_modules,我也确实看到我已经两次安装了"@types/react-redux",但是我解决了.重新安装了Typescript,仍然出现相同的(2312,14): Duplicate identifier 'LibraryManagedAttributes'.错误:(

I've rm -R node_modules, I also did see that I had "@types/react-redux" installed twice, but I fixed that. Reinstalled Typescript, and still get the same (2312,14): Duplicate identifier 'LibraryManagedAttributes'. Error :(

推荐答案

找到了答案:

  • 确保文件中包含import * as React from 'react'
  • react npm install @types/react
  • 的更新类型
  • Make sure you have import * as React from 'react' in your file
  • Update types for react npm install @types/react

这篇关于JSX错误:'JSX.IntrinsicElements类型不存在属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 03:14