I want to know what the better option is when getting values out of an object:
const [currentMonth, setCurrentMonth] = React.useState(getCurrentMonth(language).label)
or:
const { label: labelMon } = getCurrentMonth(language)
const [currentMonth, setCurrentMonth] = React.useState(labelMon)
I want to use the value only once to set the initial state.
You have to use this once it happens
useEffect(() => {
const { label: labelMon } = getCurrentMonth(language)
setCurrentMonth(labelMon )
},[]);