Is it possible to forward subtractMonth() function of react native calendars to a different component like a button?

1.7k views Asked by At

I'm building a calendar page for an app and want the month and month change arrows to be displayed next to the calendar rather than on top of it. So I have removed the header component created a View component next to it. However I am unable to figure out how to change the month when the next month button is pressed.

Here is an image of the screen for reference

1

There are 1 answers

2
keysl On BEST ANSWER

Probably using refs

const calendarRef = React.useRef()
<Calendar ref={calendarRef}/>

Now you can pass the calendarRef to other components and use this

calendarRef.addMonth(-1)

Note : Found it here https://github.com/wix/react-native-calendars/issues/764