Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct treatment of boolean view in 'views' #2368

Merged
merged 3 commits into from
Feb 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand All @@ -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
Expand Down