I'm learning typescript and I'm a bit stuck at the following error:
Property 'data' does not exist on type 'Readonly<{}> & Readonly<{ children?: ReactNode; }>'. TS2339
let data = this.props.data as any;
^
BigOGraphProps.data
is defined, why is the compiler complaining it doesn't exist?? I must be missing something crucial here. Note that I'm casting to any
because I don't really want to worry about the underlying type of AreaChart (At least not for now, first I want to get this part working).
import React from 'react';
import { AreaChart } from 'recharts';
type BigOGraphProps = {
data: {
n: number[],
oLogNData: number[],
oNData: number[],
oNLogNData: number[],
oNSq2Data: number[],
o2SqNData: number[],
oNInvData: number[],
};
};
export default class BigOGraph extends React.Component {
constructor(props: BigOGraphProps) {
super(props);
}
render() {
let leftMargin = 5;
let data = this.props.data as any;
return (
<div>
<AreaChart data={data} >
</AreaChart>
</div>
);
}
}