Fix object is possibly undefined error

This commit is contained in:
Justin Edmund 2022-11-19 18:40:32 -08:00
parent 852108c4c6
commit 90dcb54bba

View file

@ -66,8 +66,8 @@ const CharacterGrid = (props: Props) => {
// Initialize an array of current uncap values for each characters
useEffect(() => {
let initialPreviousUncapValues: { [key: number]: number } = {}
Object.values(appState.grid.characters).map(
(o) => (initialPreviousUncapValues[o.position] = o.uncap_level)
Object.values(appState.grid.characters).map((o) =>
o ? (initialPreviousUncapValues[o.position] = o.uncap_level) : null
)
setPreviousUncapValues(initialPreviousUncapValues)
}, [appState.grid.characters])