0

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>

Sole
  • 3,100
  • 14
  • 58
  • 112

1 Answers1

2
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.

SlothOverlord
  • 1,655
  • 1
  • 6
  • 16