From d1c31c2d55e5a4a74043261a4e1f5de80396e071 Mon Sep 17 00:00:00 2001 From: Mychael Go Date: Sat, 13 Jul 2024 00:12:49 +0700 Subject: [PATCH] fix: warning defaultProps in Agenda (#2620) Signed-off-by: Mychael Go --- src/Agenda.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Agenda.js b/src/Agenda.js index a076bcfff..8eb9f0e9a 100644 --- a/src/Agenda.js +++ b/src/Agenda.js @@ -9,13 +9,14 @@ import { navigate } from './utils/constants' import { inRange } from './utils/eventLevels' import { isSelected } from './utils/selection' +const DEFAULT_LENGTH = 30; function Agenda({ accessors, components, date, events, getters, - length, + length = DEFAULT_LENGTH, localizer, onDoubleClickEvent, onSelectEvent, @@ -217,11 +218,7 @@ Agenda.propTypes = { selected: PropTypes.object, } -Agenda.defaultProps = { - length: 30, -} - -Agenda.range = (start, { length = Agenda.defaultProps.length, localizer }) => { +Agenda.range = (start, { length = DEFAULT_LENGTH, localizer }) => { let end = localizer.add(start, length, 'day') return { start, end } } @@ -229,7 +226,7 @@ Agenda.range = (start, { length = Agenda.defaultProps.length, localizer }) => { Agenda.navigate = ( date, action, - { length = Agenda.defaultProps.length, localizer } + { length = DEFAULT_LENGTH, localizer } ) => { switch (action) { case navigate.PREVIOUS: @@ -243,7 +240,7 @@ Agenda.navigate = ( } } -Agenda.title = (start, { length = Agenda.defaultProps.length, localizer }) => { +Agenda.title = (start, { length = DEFAULT_LENGTH, localizer }) => { let end = localizer.add(start, length, 'day') return localizer.format({ start, end }, 'agendaHeaderFormat') }