I have this component:
const arr = [];
const test = (date) => {
arr.push(date);
};
ReactDOM.render(
<Space direction="vertical" size={12}>
<DatePicker
onChange={test}
open={true}
showNow={false}
dateRender={(current) => {
const style = {};
if (arr.includes(current)) {
style.border = "1px solid red";
style.borderRadius = "50%";
}
return (
<div className="ant-picker-cell-inner" style={style}>
{current.date()}
</div>
);
}}
/>
</Space>,
document.getElementById("container")
);
The idea is next: when I click on the specific date it should be applied next styles:
if (arr.includes(current)) {
style.border = "1px solid red";
style.borderRadius = "50%";
}
I don't now why, but it does not work. I want when I will click on the date to apply these styles and when I click back on the same cell to deselect the styles, but my condition does not work. Who can help?
Link to codesandbox.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…