I suspect that this:
React.useState<ItemListData[] | null>
means "the type can be an array of ItemListData
or the type can be null
". Which means you either have an array or you have null
, but the array itself must contain ItemListData
.
What you want is "the type can be an array of either ItemListData
or null
". Which would mean that the type itself must always be an array, but that array can contain either ItemListData
or null
.
Perhaps something like this:
React.useState<(ItemListData | null)[]>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…