Мне трудно использовать пользовательскую панель инструментов с реагирующим большим календарем и машинописью.Я пытаюсь получить доступ к оригинальным методам просмотра «следующий, предыдущий» «месяц, день, неделя».Я внимательно прочитал ... https://github.com/intljusticemission/react-big-calendar/issues/623 https://github.com/intljusticemission/react-big-calendar/issues/818 http://intljusticemission.github.io/react-big-calendar/examples/index.html#prop-components
Пользовательский интерфейс отображается нормально, без ошибок, Теперь мне нужен доступ к оригинальным методам, чтобы я мог манипулироватькалендарь.
Основная проблема в том, что моя кнопка срабатывает, но на самом деле ничего не перемещается.
Некоторые проблемы, которые я считаю ...
- Я на самом деле не использую navateMethod, как я думаю
- Дата и дата по умолчанию в BigCalendar isnне меняется, потому что я перезаписываю его одним и тем же днем каждый раз, когда нажимаю?
- мне нужно реализовать этот пример из их документов?
Custom views can be any React component, that implements the following interface:
interface View {
static title(date: Date, { formats: DateFormat[], culture: string?, ...props }): string
static navigate(date: Date, action: 'PREV' | 'NEXT' | 'DATE'): Date
}
У кого-нибудь естьПример, на который я мог бы посмотреть ???
Вот мой полный исходный код.
import React from 'react'
import { MainContent } from '../../../common/templates/partials'
import BigCalendar from 'react-big-calendar'
import ToolBar from 'react-big-calendar'
import Icon from 'app/common/components/Icon'
import moment from 'moment'
const styles = require('./CalendarUI.scss')
BigCalendar.momentLocalizer(moment) // or globalizeLocalizer
const events = [
{
start: new Date(),
end: new Date(),
title: 'Some title',
},
]
class CustomToolbar extends ToolBar {
render() {
// tslint:disable-next-line:no-console
console.log(this.props, this)
/* tslint:disable-next-line */
const {label, onNavigate} = this.props as any
return (
<div className="rbc-toolbar">
<div>
{/* tslint:disable-next-line */}
<button onClick={() => this.props.onNavigate ? onNavigate(null as any, 'PREV') : undefined}>
<Icon icon="B" />
</button>
<label className="label-date">{label}</label>
{/* tslint:disable-next-line */}
<button onClick={() => this.props.onNavigate ? onNavigate(null, 'NEXT') : undefined}>
<Icon icon="A" />
</button>
</div>
<div>
<span className="rbc-btn-group">
<button>Month</button>
<button>Day</button>
<button>Week</button>
</span>
<button className="btn btn-back">
<Icon icon="R" />
</button>
<button className="btn btn-back">
<Icon icon="meet_now" />
</button>
</div>
</div>
)
}
}
const logger = (data: string) =>
// tslint:disable-next-line:no-console
console.log(data)
const CalendarUI = () => (
<MainContent>
<div className={styles.calendarContainer}>
<BigCalendar
defaultDate={moment().toDate()}
defaultView="month"
events={events}
components={{ toolbar: CustomToolbar }}
startAccessor="startDate"
endAccessor="endDate"
onView={logger}
date={moment().toDate()}
/>
</div>
</MainContent>
)
export default CalendarUI