Skip to content
Advertisement

convert array of full date to array of month in react

i try to convert array of date to array of month in react

JavaScript

when i push convertedDateToMonths to array every time i rewrite month in output i got only 1 month when i do console.log(month) what i do wrong ?

Advertisement

Answer

You need to call the setMonth function with the updated table and not on each .map loop. So just process the links with a simple map to get the list of months and call setMonth with the result of it:

JavaScript

Edit modern-waterfall-c20vi

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement