I have an Object named Parent and it has an array of another object named Child and I dont know how to give its initial value when called in state of a component class.
I tried to casting it with as Child[] but it still doesn't work
Parent :
export interface Parent {
id: string,
child : Child[]
}
State in Component
interface State {
parent: Parent
}
How I initialize the value
constructor(props: Props) {
super(props);
this.state = {
parent: {
id: "",
child: [] as Child[]
}
}
}
Thank You.
as Child[]is unecessary.