I have this prop that I’ll be passing down:
checkboxesState
its original value is an empty object
{}
but it will change when user clicks on checkboxes, so it can look like this:
{
"option1": true,
"option2": true,
"option3": true,
"option4": true,
...
...
}
My question is, How can I define its type in the interface?
I have this but I have a feeling it’s missing something:
interface FieldProps {
checkboxState: { [key: string]: boolean };
}
2
Answers
Maybe try
This means that all keys must be a string and all values must be a boolean
I guess it is what you want