i want list of dates that i select but smth is not working

import React, { useEffect, useState } from "react";
import Css from '../Css/Weak.module.css'

function Weak(props) {
let [selectedDate , setSelectedDate] = useState([])
useEffect(()=>{
console.log(selectedDate)
},[selectedDate])

return Array.from(Array(7)).map((_, j) => {
let date = new Date(props.year, props.monthIndex, props.index * 7 + j + 1);
let month = date.getMonth();
if (month !== props.monthIndex) {
return <p key={j} ></p>;
}
return <p key={j} onClick={(e)=>{
setSelectedDate([...selectedDate, e.target.innerText]);
}} className={Css.date}>{date.getDate()}</p>;
});
}

export default Weak;
import React, { useEffect, useState } from "react";
import Css from '../Css/Weak.module.css'

function Weak(props) {
let [selectedDate , setSelectedDate] = useState([])
useEffect(()=>{
console.log(selectedDate)
},[selectedDate])

return Array.from(Array(7)).map((_, j) => {
let date = new Date(props.year, props.monthIndex, props.index * 7 + j + 1);
let month = date.getMonth();
if (month !== props.monthIndex) {
return <p key={j} ></p>;
}
return <p key={j} onClick={(e)=>{
setSelectedDate([...selectedDate, e.target.innerText]);
}} className={Css.date}>{date.getDate()}</p>;
});
}

export default Weak;
can someone even explain whats hapenning here
1 Reply
Anonymous DEV
Anonymous DEV13mo ago
oh i got it thanks anyways
Want results from more Discord servers?
Add your server