Reputation: 3340
What is the type for a object in React/Typescript for example:
const [value, setValue] = React.useState<any>({});
if I need to define it as an object what type would I put in, instead of <any>
Upvotes: 0
Views: 6694
Reputation: 2037
interface MyObject {
[k: string]: any;
}
const [value, setValue] = React.useState<MyObject>({});
[k: string]: any; means that property must be a string, and it's value are any.
Upvotes: 3