I have a question about those 2 conditional statements as I think they are.
- [array]?.map() syntax my assumption it checks if the previous array has a value so in case it is empty it won't crash the app.
{context.somestate[props.someprops]?.map((someEl) => (
<compnent key={someEl.id} />
))}
- a chunk from a code that is used to add an item in to a state in react in the reducer file, my assumption here it is also checking for empty value ?
case ADD_SOME_ITEM:
return {
...state,
someItems: {
...state.someItems,
[action.index]: [
...(state.someItems[action.index] ?? []),
{ id: action.id }
]
}