From 0e6b7717985e626413347fcc196d38c0d071d759 Mon Sep 17 00:00:00 2001 From: rajeshrajesh Date: Fri, 17 Feb 2023 22:52:26 +0530 Subject: [PATCH] fix: correct treatment of boolean view in 'views' (#2368) --- src/Calendar.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Calendar.js b/src/Calendar.js index 8a2cb6a28..cf70d2391 100644 --- a/src/Calendar.js +++ b/src/Calendar.js @@ -26,7 +26,16 @@ import mapValues from 'lodash/mapValues' import { wrapAccessor } from './utils/accessors' function viewNames(_views) { - return !Array.isArray(_views) ? Object.keys(_views) : _views + if (Array.isArray(_views)) { + return _views + } + const views = [] + for (const [key, value] of Object.entries(_views)) { + if (value) { + views.push(key) + } + } + return views } function isValidView(view, { views: _views }) { @@ -47,7 +56,7 @@ class Calendar extends React.Component { * const localizer = globalizeLocalizer(globalize) * ``` * moment - * ```js + * ``js * import {momentLocalizer} from 'react-big-calendar' * import moment from 'moment' * // and, for optional time zone support