BugiDev / react-native-calendar-strip

Easy to use and visually stunning calendar component for React Native.
MIT License
951 stars 326 forks source link

How To Set Selected Date #201

Closed dhussong closed 4 years ago

dhussong commented 4 years ago

I see a note in the readme about using setSelectedDate(date) and above it there is a note that "Methods may be accessed through the instantiated component's ref." I don't understand what this means. Can you provide an example as to how to use the setSelectedDate method? Thanks!

peacechen commented 4 years ago

Direct manipulation via refs is a feature of React. I recommend that you search resources such as React Native's documentation and Stack Overflow to learn how to use them.

https://stackoverflow.com/questions/36716207/react-native-accessing-refs-in-a-custom-component

https://medium.com/@rossbulat/how-to-use-react-refs-4541a7501663

Generally speaking, you should avoid calling a component's internal methods if there's a prop to control it. In this case, use the selectedDate prop.