提问人:Karine Brandelli Padilha 提问时间:10/12/2023 最后编辑:ADysonKarine Brandelli Padilha 更新时间:10/13/2023 访问量:29
使用 dayCellDidMount 在完整日历上自定义一天时的错误
Bug when using dayCellDidMount to customize a day on fullcalendar
问:
当我将我的 react-dom 更新到 v18 时,这个错误突然出现。 我做了一个逻辑,将每月的第一天更改为,例如,“01 oct”。 但是在新版本的 react-dom 中,它有点“混合”模式和更改的日期。
const customDayLabel = (date: Date, view: CalendarView): void => {
if (view === CalendarView.Month) {
const currentDate = new Date(date).setDate(DAY_ONE)
const dates = [addMonths(currentDate, ONE_MONTH), currentDate]
for (const targetDate of dates) {
const dataDate = format(targetDate, 'yyyy-MM-dd')
const element = document.querySelector(
`.fc-daygrid-day[data-date="${dataDate}"] a`
)
if (element) {
const dateLabel = format(targetDate, 'dd MMM.')
element.innerHTML = dateLabel
}
}
}
}
const Calendar = ({
setCalendarRef,
view,
date,
...otherProps
}: CalendarProps) => {
const headerView = view || otherProps.initialView || CalendarView.Month
const dayRender = useCallback(() => {
customDayLabel(date, headerView)
}, [date, headerView])
return (
<FullCalendar
ref={setCalendarRef}
editable
droppable
navLinks
allDayText=''
locale='pt-BR' // for 0-23 hour format
forceEventDuration
moreLinkText='mais'
headerToolbar={false}
fixedWeekCount={false}
plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin]}
slotLabelFormat={slotLabelFormat}
dayPopoverFormat={dayPopoverFormat}
dayHeaderContent={customHeader}
dayCellDidMount={dayRender}
initialDate={date}
{...otherProps}
/>
)
}
我能做些什么来修复它?
我试图替换 ,但它只呈现我更改的标签。dayCellDidMount
dayCellContent
答: 暂无答案
评论