Fix the calendar component to avoid re-rendering.

master
Tom Hacohen 7 years ago
parent 8186055537
commit b876a90a5a

@ -35,6 +35,12 @@ class Calendar extends React.PureComponent {
constructor(props: any) { constructor(props: any) {
super(props); super(props);
this.state = {}; this.state = {};
this.onNavigate = this.onNavigate.bind(this);
}
onNavigate(currentDate: Date) {
this.setState({currentDate});
} }
render() { render() {
@ -42,13 +48,11 @@ class Calendar extends React.PureComponent {
<div style={{width: '100%', height: 500, padding: 10}}> <div style={{width: '100%', height: 500, padding: 10}}>
<BigCalendar <BigCalendar
events={this.props.entries} events={this.props.entries}
onSelectEvent={(event: any) => { onSelectEvent={this.props.onItemClick as any}
this.props.onItemClick(event);
}}
formats={{agendaHeaderFormat: agendaHeaderFormat}} formats={{agendaHeaderFormat: agendaHeaderFormat}}
eventPropGetter={eventPropGetter} eventPropGetter={eventPropGetter}
date={this.state.currentDate} date={this.state.currentDate}
onNavigate={(currentDate: Date) => { this.setState({currentDate}); }} onNavigate={this.onNavigate}
/> />
</div> </div>
); );

Loading…
Cancel
Save