'Object values are lost after useState
I have an object with time intervals fot every day of week.
{
mon: [['2022-05-02T22:30:00.100Z', '2022-05-03T02:00:00.309Z'], ...],
tues: [[]],
...
}
So when I'm trying to use useState
const defaultIntervals = getDaysAndIntervals({ metaData })
const [daysAndIntervals, setDaysAndIntervals] = useState(defaultIntervals)
the defaultIntervals is correct, but daysAndIntervals converting to
{
mon: [],
tues: []
}
The values of every key in this object is empty array. Could please tell me why?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
