I'm trying to use react hooks in my project and I have a problem with useState when I use array as value.
As you can see in my code below, when I display zoneItems
that it should be like items
array I get an empty array all the time. Would you have an explanation why?
When I use an object instead of array it works
const ShippingCostZone = ({ zone, datas, selectedProducts, getProductById }) => {
const items = datas.items.filter(item => item.zoneId === zone.id)
console.log('========> items', items) // ---- SHOW the good values
const [zoneItems, updateItems] = useState(items)
console.log('========> zoneItems ', zoneItems) // ---- SHOW all the time []
.........
Thanks in advance