BugiDev / BugiDev/react-native-calendar-strip
setSelectedDate is not working
- Dominant language
- JavaScript
- Stars
- 976
- Forks
- 336
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I'm getting an issue when scrolling to the selected date
The date is selected when I manually scroll to the section. But it does not scroll automatically on date changes.
I have tried with setSelectedDate but not working for me.
> "react-native": "0.63.4",
> "react-native-calendar-strip": "^2.2.5",

I have created a custom component. The updated date will be passed via props.
```
const CustomStripCalender = ({
value,
onDateChange,
}: {
value?: any;
onDateChange?: (value: any) => void;
}) => {
const [currentDate, setCurrentDate] = useState(moment());
const calenderRef = useRef(null);
const handleOnDateSelect = (date) => {
setCurrentDate(date);
if (onDateChange) {
onDateChange(date);
}
};
useEffect(() => {
if (moment(value).isValid()) {
const _value = moment(value);
setCurrentDate(_value);
if (calenderRef?.current) {
calenderRef?.current?.setSelectedDate(_value);
}
}
}, [value]);
return (
<>
{moment(currentDate).format('DD MMMM,YYYY')}
);
};
```
How to resolve this issue?.
Thanks for the awesome library.
Contributor guide
Assessment
This issue has not been assessed yet.