How can I export my data from a react stateful component to a simple JS file??
for example: From here: (I want to export dates)
function Calendar() {
const [selectedDay, setSelectedDay] = useState([
{year: 2021, month:11, day:11},
{year: 2022, month: 1, day: 2,
]);
const dates = selectedDay.map(d => d)
}
To here a simple js file ( builder.js ):
(I want to show dates in ..... place)
export const buildDaysCells = () => {
const v = [];
for (let i = 0; i < MONTHS_PER_YEAR * NUM_OF_YEARS; i += 1) {
const startMonth = i;
v.push({
id: `m${startMonth}`,
title: `${DAYS_NAMES[i]} ${......}`,
});
}
return v;
};