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;
1 Reply
oh i got it thanks anyways