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

Setting a view as 'false' in views prop should turn it off #2316

Open
5 tasks done
kronaemmanuel opened this issue Dec 16, 2022 · 9 comments
Open
5 tasks done

Setting a view as 'false' in views prop should turn it off #2316

kronaemmanuel opened this issue Dec 16, 2022 · 9 comments
Labels

Comments

@kronaemmanuel
Copy link

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/s/react-big-calendar-example-forked-o0b8z0?file=/src/App.js

Bug description

The documentation for creating a custom view shows this pattern being used:

const {views, ...otherProps} = useMemo(() => ({
  views: {
    month: true,
    week: CustomWeekView,
    day: true
  },
  // ... other props
}), [])

This makes it seem like if I pass day: false, the day view will disappear. However, that's not the case.

I would be happy to explore the codebase a little and fix this. Lemme know.

Expected Behavior

The day view should disappear when day: false is passed to the views prop.

Actual Behavior

The day view still appears, and it displays the error: View.title is not a function because it is still expecting for there to be a view there.

react-big-calendar version

1.5.0

React version

18.2.0

Platform/Target and Browser Versions

Firefox 104.0

Validations

  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a react-big-calendar issue and not an implementation issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR
@bu6n
Copy link
Contributor

bu6n commented Dec 16, 2022

You can hide the view by just not writing it, like:

const {views, ...otherProps} = useMemo(() => ({
  views: {
    month: true,
    week: CustomWeekView,
  },
  // ... other props
}), [])

This is still a bug, since the documentation says you should be able to write day: false. I think the problematic code is somewhere here:
https://github.com/jquense/react-big-calendar/blob/master/src/Calendar.js#L958

@jalalmanafi
Copy link

Hi @bu6n , is this issue still active ? I want to work on this

@bu6n
Copy link
Contributor

bu6n commented Jan 8, 2023

Yes this is still a bug if you wanna try to solve it!

@jalalmanafi
Copy link

Great, can you assign me this issue?

@jalalmanafi
Copy link

jalalmanafi commented Jan 9, 2023

@bu6n I searched the codebase, i found this, there has no boolean type month or day props. That is why it is not working for the "day or month view". Also, we can send any props to views and this will make a visual bug too. I found the file where written PropsTypes for the views prop and I will work on this, any feedback or advice is welcome :)

Screenshot 2023-01-09 at 08 44 52

Screenshot 2023-01-09 at 08 45 07
Screenshot 2023-01-09 at 08 45 33

@rajeshmn47
Copy link
Contributor

Hi @bu6n , is this issue still active ? I want to work on this.I already found solution.

@rajeshmn47
Copy link
Contributor

Screenshot from 2023-02-15 16-33-50
we can fix using this

@bu6n
Copy link
Contributor

bu6n commented Feb 15, 2023

Can you make a PR and then someone will review?

@rajeshmn47
Copy link
Contributor

rajeshmn47 commented Feb 15, 2023 via email

rajeshmn47 added a commit to rajeshmn47/react-big-calendar that referenced this issue Feb 15, 2023
rajeshmn47 added a commit to rajeshmn47/react-big-calendar that referenced this issue Feb 15, 2023
rajeshmn47 added a commit to rajeshmn47/react-big-calendar that referenced this issue Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants