Skip to content

Use React-Calendar with react-swipeable #569

Answered by wojtekmaj
MDcod asked this question in Q&A
Discussion options

You must be logged in to vote

React-Calendar accepts ref, but ref points to Calendar component and its internals, and not the wrapper rendered by Calendar. handlers returned by useSwipeable is just { ref } from what I can see, and I assume ref expects to be hooked to a DOM element, not React component. That's why it doesn't work.

If you rename ref to inputRef in handlers, it works!
https://codesandbox.io/s/react-calendar-react-swipeable-kxw92

If you're thinking what I'm thinking, here's how to implement switching views with swipe. You'll need to have activeStartDate and view controlled so that onSwiped has some data to begin with.
https://codesandbox.io/s/react-calendar-react-swipeable-change-view-on-swipe-f0p4i

Pleas…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@MDcod
Comment options

@MDcod
Comment options

@MDcod
Comment options

@wojtekmaj
Comment options

@laocker96
Comment options

Answer selected by MDcod
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants