Description: I'm trying to update my useState
, newCase, with property values coming from a form.
Problem: Assigning the value results in the error: Type 'string' is not assignable to type 'never', and I don't know how to fix it.
Here's the interface of a case object:
export interface ICases {
materials: Material[]
finalActivity: boolean
existingCase: boolean
timestamp: Timestamp
description: string
userId: string
caseName: string
geoLocation: string
done: boolean
id: string
parentActivityID: string
first: boolean
}
And here is the relevant code to the AddCase modal.
const [newCase, setNewCase] = useState<ICases>()
const updateCase = (key: keyof ICases, value: string) => {
const updatedCase = newCase ? { ...newCase } : ({} as ICases)
updatedCase[key] = value
setNewCase(updatedCase)
}