Error TS2339: Property '{}' does not exist on type 'IntrinsicClassAttributes…'

Asked
Active3 hr before
Viewed126 times

7 Answers

ts2339existintrinsicclassattributespropertyerror
90%

Obviously I'm only including the basics and there is much more to both of these classes but I'm still getting an error when I try and run what looks to me like valid code. The exact error that I'm getting:,The above managed to work for me. Passing explicitly the props that the component is expecting from the container seemed to work and both components rendered properly.,When I first encountered the error I thought it was because I wasn't passing in an interface defining my props, but I created that (as you can see above) and it still doesn't work. I'm wondering, is there something I'm missing? ,Check https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/class_components/ for more info

So the container component stayed the same, but the child component changed a bit:

interface IChildComponentProps extends React.Props<any> {
  ... (other props needed by component)
}

interface PassedProps extends React.Props<any> {
  propToPass: any
}

class ChildComponent extends React.Component<IChildComponentProps & PassedProps, any> {
  ...
}

....
export default connect<{}, {}, PassedProps>(mapStateToProps, mapDispatchToProps)    (ChildComponent);
load more v
88%

You can solve it by specifying the types of the props of whatever page component you're using and adding a path: string; to them. That does not seem like a good idea though because you won't be actually using that prop and that will cause other errors with linters and the like.,Doesn't mean you'll always take advantage of that. But the types are being augmented only in the scope of your project. In another project that doesn't use reach, that hint won't be there.,My concern though is every React component now has that path attribute, whether I intend to use it for routing or not.,I'm sure there are other solution but at this time I don't really know of any as I'm not a TypeScript expert. All I know that this error is due to path not being a typed prop of the page you're using.

import { RouteComponentProps } from '@reach/router';

interface ISignupPageProps extends RouteComponentProps {
  someProp: string;
}

class SignupPage extends React.Component<ISignupPageProps> {
  // ...
}
load more v
72%

import React, { FunctionComponent } from "react";
import { RouteComponentProps } from "@reach/router";

type Props = { component: FunctionComponent } & RouteComponentProps;

const Route: FunctionComponent<Props> = ({ component: Component, ...rest }) => (
  <Component {...rest} />
);

export default Route;
65%

Property 'nmae' — The “properties” are the attributes on the <input> tag. So this error is about “nmae=”…"”.,Property 'fieldName'— We saw this language before with the <input>’s nmae attribute, but now it’s referring to a “property” on the this.props object, rather than one on an HTML tag.,That comes together to mean that this.props has an optional children property, but no fieldName property.,There’s another error that can come up with HTML: using the wrong type for an attribute. Let’s add a size to the <input> and see what happens:

For starters, let’s look at using standard DOM elements in JSX. TypeScript will check to make sure that every attribute you put on an HTML tag exists and is of the right type. For example:

render() {  return <input type="text" name="color" />;}
load more v
75%

How to solve Type Property '' does not exist on type 'IntrinsicAttributes & Function'? ,Type '{ reload: (e: MouseEvent) => void; }' is not assignable to type 'IntrinsicAttributes & Function'. Property 'reload' does not exist on type 'IntrinsicAttributes & Function',Also note that I've changed filterComponent to be FilterComponent as lowercase component namespace is reserved for HTML primitives,I have a parent component like so

I have a parent component like so

import filterComponent from 'filter/filterComponent'


  const reloadHandler = useCallback(
    (event: MouseEvent) => {
      event.preventDefault();
     // my logic
    },
    [Reload, Fetching]
  );

const parent = () => { 
return (
    <filterComponent reload={reloadHandler} /> 
   )
}

Filter Component:

export const filterComponent = (filter: Function, reload: Function) => { 
    return (
       <Button onClick={reload} />
   )
}
load more v
40%

Ask questionsTS2339: Property 'href' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Link> & Readonly<{ children?: ReactNode; }> & Read... ,I have added a "Spinner" component to one of the pages and that worked fine, but when I add a "Link" component to the page the TypeScript compiler throws the following error message: ClientApp/components/FetchData.tsx(33,19): error TS2339: Property 'href' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Link> & Readonly<{ children?: ReactNode; }> & Read...'. node_modules/office-ui-fabric-react/lib/components/Link/Link.Props.d.ts(7,43): error TS2694: Namespace 'React' has no exported member 'AllHTMLAttributes'.,I have added office-ui-fabric-react version 5.20.2, and @types/prop-types version 15.5.2 to package.json.

I have created a new ASP.NET Core project using the "React" template that is included in Visual Studio 2017. The full source code of the template can be found here. Here is a direct link to the package.json, and tsconfig.json.

I have added office-ui-fabric-react version 5.20.2, and @types/prop-types version 15.5.2 to package.json.

office - ui - fabric - react
load more v
22%

1How to write a proper curl to the method of Spring MVC Controller?,Find more questions by tags ReactTypeScript


import * as React from 'react';
import Child from './child';

class Parent extends React.Component<{}, {}> {
constructor(props){
super(props);
}


 state = {
 items: [
{
 id: 1,
 title: 'Test-1'
},
{
 id: 2,
 title: 'Test-3'
}
]
}

 render() {
 return (
the <div>
 <child items="{this.state.items}/">
</child></div>
);
}
}

interface Props {
 items: any;
}

class Child extends React.Component<props {}> {
constructor(props){
super(props);
}

 render() {
 const items = this.props.items;
 return (
the <div>
</div>
);
}
}</props>
load more v

Other "ts2339-exist" queries related to "Error TS2339: Property '{}' does not exist on type 'IntrinsicClassAttributes…'"