MarceloPrado / flash-calendar

The fastest React Native calendar 📆⚡
https://marceloprado.github.io/flash-calendar/
MIT License
1.09k stars 33 forks source link

Can I create two instances of the <Calendar.List /> with useDateRange hooks ? #51

Closed ioeldev closed 1 month ago

ioeldev commented 3 months ago

I have two screens with the Calendar.List but when one update the state of useDateRange it gets reflected on the second component, even though the Calendar.List have two different "key" props. Is it possible to instantiate the useDateRange twice ?

MarceloPrado commented 3 months ago

The useDateRange hook is a plain React hook that exposes a useState's value + some setters. Did you try something like this?

const YourApp = ({ currentScreen }) => {
  const dateRangePropsForFirstScreen = useDateRange()
  const dateRangePropsForSecondScreen = useDateRange()

  return currentScreen === 'one' ? 
    <ScreenOne {...dateRangePropsForFirstScreen} /> : 
    <ScreenTwo {...dateRangePropsForSecondScreen} />;
}
ioeldev commented 3 months ago

Will try, it's just that i am initializing the useDateRange inside of each components so i thought i wouldn't interfere

MarceloPrado commented 3 months ago

A repro example would be helpful to understand what's going on

MarceloPrado commented 1 month ago

@ioeldev fixed in version 1.1.0