I am using typescript and react.js in an asp.net core application. I am getting an error TS property 'Persons' does not exist on type readonly. Can anyone tell me how to overcome this?
export default class HelloWorld extends React.Component<{}, {}> {
constructor(props: any) {
super(props);
this.state = {
persons: [
{ name: 'Max', age: 28 },
{ name: 'Max', age: 28 }
]
}
}
public render() {
return (
<div>
<Person {this.state.persons[0].name} age="28"> My hobbies: racing</Person>
</div>
);
}
import * as React from 'react';
const person = (props: any) => {
return (
<div>
<p> Im {props.name} {props.age}</p>
<p>{props.children}</p>
</div>
)
};
export default person;
Thanks
Personsshown in this code, so either you are paraphrasing the error message or you are not showing the right code.