Reputation: 358
I have a component that gets 2 props, one is another component and the second is a JSON file:
interface HeaderProps {
title: ReactElement<typeof Title>;
data: any;
}
The prop 'title' is very specific and shows that only the component <Title />
can be passed there.
How can I specify the type of the prop data
so instead of any
it will be for JSON type only?
Upvotes: 1
Views: 5492
Reputation: 1411
I believe you are looking for an "object" with dynamic key of any type.
data: { [key:string]: any }// if array then {[key:string]: any}[]
Upvotes: 2