I am dispatching an action that contains a state that I updated immediately before. But my item.id is always empty (its default value). I assume the item state hasnt been able to update BEFORE it passed to dispatch(addItem(...)). Is this the case? If so, how can I go about this.
<Pressable
onPress={() => item.name.trim() ?
(
setItem(prevState => ({ ...prevState, id: item.name + today.getTime()})),
dispatch(addItem(item)),
setShowModal(false)
)
:
alert('Please enter name')
}
style={styles.button}
>