Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript .tsx组件中的.js组件-没有与此调用匹配的重载/类型IntrinsicatAttribute上不存在属性_Javascript_Reactjs_Typescript - Fatal编程技术网

Javascript .tsx组件中的.js组件-没有与此调用匹配的重载/类型IntrinsicatAttribute上不存在属性

Javascript .tsx组件中的.js组件-没有与此调用匹配的重载/类型IntrinsicatAttribute上不存在属性,javascript,reactjs,typescript,Javascript,Reactjs,Typescript,我试图在.tsx函数组件的render()函数中包含.jsx(或.js)React类有状态组件。 根据我的尝试,我会得到不同的错误“没有与此调用匹配的属性” 我尝试了在github上看到的东西,比如: //... /* tslint:disable */ const JSProfileDetails: any = ProfileDetails; /* tslint:enable */ return ( // ... <JSProfileDetails

我试图在.tsx函数组件的render()函数中包含.jsx(或.js)React类有状态组件。 根据我的尝试,我会得到不同的错误“没有与此调用匹配的属性”

我尝试了在github上看到的东西,比如:

//...
  /* tslint:disable */
  const JSProfileDetails: any = ProfileDetails; 
  /* tslint:enable */

  return (
// ...
   <JSProfileDetails
        profileName={profileName}
        profileDetails={profileDetails}
        profileInitialValues={profileInitialValues}
      />
我得到的确切错误是:

o overload matches this call.
  Overload 1 of 2, '(props: TypographyProps, context?: any): ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Componen
t<any, any, any>)>) | (new (props: any) => Component<any, any, any>)> | Component<...>', gave the following error.
    Type 'string' is not assignable to type 'ElementType<HTMLAttributes<HTMLElement>>'.
  Overload 2 of 2, '(props: PropsWithChildren<TypographyProps>, context?: any): ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (prop
s: any) => Component<any, any, any>)>) | (new (props: any) => Component<...>)> | Component<...>', gave the following error.
    Type 'string' is not assignable to type 'ElementType<HTMLAttributes<HTMLElement>>'.
o重载与此调用匹配。
重载1/2'(道具:排字术,上下文?:任意):ReactElement ReactElement Componen
t) >)|(new(props:any)=>Component)>| Component'给出了以下错误。
类型“string”不可分配给类型“ElementType”。
重载2/2’(props:PropsWithChildren,context?:any):ReactElement ReactElement Component)>)|(new(props:any)=>Component)>| Component),给出了以下错误。
类型“string”不可分配给类型“ElementType”。
同时,VS代码错误为:

Type '{ profileName: string; modelId: string; definitionName: string; profileDetails: ProfileUI; profileInitialValues: any; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<RouteComponentProps<any, StaticContext, any>, never>, any, any>> & Readonly<Pick<RouteComponentProps<any, StaticContext, any>, never>> & Readonly<...>'.
  Property 'profileName' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<RouteComponentProps<any, StaticContext, any>, never>, any, any>> & Readonly<Pick<RouteComponentProps<any, StaticContext, any>, never>> & Readonly<...>'.
类型“{profileName:string;modelId:string;definitionName:string;profileDetails:ProfileUI;profileInitialValues:any;}”不能分配给类型“intrinsicatAttribute&IntrinsicClassAttributes&Readonly&Readonly”。
类型“IntrinsicatAttributes&IntrinsicClassAttributes&Readonly&Readonly”上不存在属性“profileName”。

我刚刚遇到了一个非常类似的问题。事实证明,根据子组件上的proptypes(或者可能是TypeScript的推断),我使用无效的prop调用JSX子组件

const profile=someQuery.profile |{id:-1,名称:“Guest”}
//...

id
此处应为字符串,而不是数字。将
-1
转换为
“-1”
解决了我的问题。

这是两个问题的组合:

首先,错误
类型“string”不可分配给类型“ElementType”
是指一个完全不同的组件,一个使用
材质ui
排版
组件的组件,这里提出并回答了一个问题:。当我添加这张罚单时,我已经升级了依赖项,同时尝试了一些事情,新版本的
materialui
抛出了这个新错误

其次,类型“IntrinsicatAttributes&IntrinsicClassAttributes&Readonly&Readonly”上不存在错误
属性“profileName”。
当呈现
.js
组件中的
.tsx
组件时,它会显示出来,使用我在问题中已经包含的语法,它确实被静音了:

  /* tslint:disable */
  const JSProfileDetails: any = ProfileDetails; 
  /* tslint:enable */

  return (
   <JSProfileDetails
        profileName={profileName}
        profileDetails={profileDetails}
        profileInitialValues={profileInitialValues}
      />
/*tslint:禁用*/
const JSProfileDetails:any=ProfileDetails;
/*tslint:启用*/
返回(

感谢您抽出时间向所有提供输入的人表示感谢。

这里没有足够的信息来了解发生了什么。此外,无法键入?在Typescript中?为什么不?我的最佳猜测是您没有正确调用类组件,Typescript拒绝了它。请告诉我我可以提供哪些额外信息。ProfileDetails.jsx组件创建在componentDidMount和componentWillUnmount中创建我无法键入的方法:``componentDidMount(){this.unblock=this.props.history.block((nextLocation,action)=>{if(this.props.isFormDirty&!this.state.confirmedNavigation){this.setState({nextLocation,nextAction:action,showPreventNavigationModal:true,});}返回!this.props.isFormDirty;});}组件将卸载(){this.unblock();}“``创建一个最小的复制示例,最好是带有一个指向演示问题的TS游乐场的链接。例如,我试图在函数组件栏中呈现类Foo(所有用于Foo的代码)(所有用于Bar的代码),编译器给出了这个确切的错误。你说的“没有正确调用类组件”是什么意思?请将您的实际代码张贴在某处。
  /* tslint:disable */
  const JSProfileDetails: any = ProfileDetails; 
  /* tslint:enable */

  return (
   <JSProfileDetails
        profileName={profileName}
        profileDetails={profileDetails}
        profileInitialValues={profileInitialValues}
      />