Starting with React, Nextjs with typescript
I have the following class which gives an error while accessing avatar and name
Property does not exists on type readonly
How can I typecast the properties properly?
React.Component is a generic class. You can specify the props there:
interface AvatarProps {
avatar?: string;
name: string;
}
class Avatar extends React.Component<AvatarProps> {
If you leave it out, the default is to assume there are no props.
React.Component<{ x, y }: CustomProps> works like it does with functional components