Issue
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 };
}
Solution
Maybe try
Record<string,boolean>
This means that all keys must be a string and all values must be a boolean
Answered By - Jesse
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.