HosseinShabani / react-native-modern-datepicker

A customizable calendar, time & month picker for React Native (including Persian Jalaali calendar & locale)
MIT License
578 stars 164 forks source link

require cycle warnings #28

Open hrahul2605 opened 4 years ago

hrahul2605 commented 4 years ago

Warning

WARN     Require cycle: components/DatePicker/datePicker/DatePicker.js -> components/DatePicker/datePicker/components/SelectTime.js -> components/DatePicker/datePicker/DatePicker.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.

[Fri Jul 10 2020 11:32:13.950]
WARN     Require cycle: components/DatePicker/datePicker/DatePicker.js -> components/DatePicker/datePicker/components/Calendar.js -> components/DatePicker/datePicker/components/index.js -> components/DatePicker/datePicker/components/Header.js -> components/DatePicker/datePicker/DatePicker.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.

[Fri Jul 10 2020 11:32:13.951]
WARN     Require cycle: components/DatePicker/datePicker/DatePicker.js -> components/DatePicker/datePicker/components/Calendar.js -> components/DatePicker/datePicker/components/index.js -> components/DatePicker/datePicker/components/Days.js -> components/DatePicker/datePicker/DatePicker.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.

[Fri Jul 10 2020 11:32:13.953]
WARN     Require cycle: components/DatePicker/datePicker/DatePicker.js -> components/DatePicker/datePicker/components/Calendar.js -> components/DatePicker/datePicker/components/index.js -> components/DatePicker/datePicker/components/SelectMonth.js -> components/DatePicker/datePicker/DatePicker.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.

[Fri Jul 10 2020 11:32:13.954]
WARN     Require cycle: components/DatePicker/datePicker/components/Calendar.js -> components/DatePicker/datePicker/components/index.js -> components/DatePicker/datePicker/components/Calendar.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.

[Fri Jul 10 2020 11:32:13.956]
WARN     Require cycle: components/DatePicker/datePicker/DatePicker.js -> components/DatePicker/datePicker/components/Calendar.js -> components/DatePicker/datePicker/DatePicker.js

I tend to have this warning message everytime my app reloads,can we update the package with this warning removed?

salarihamid commented 3 years ago

Hi . any plan to fix the warning ?

hrahul2605 commented 3 years ago

Hey @Unknown051 , i fixed it in my code by seprating the CalenderContext in a different file and importing the same where ever needed.

salarihamid commented 3 years ago

Hey @Unknown051 , i fixed it in my code by seprating the CalenderContext in a different file and importing the same where ever needed.

@hrahul2605 thanks for the reply . I'm quite new to the npm and react native so i didn't get what you saying . I'm using it like :

import DatePicker from 'react-native-modern-datepicker'; <DatePicker options={defaultOptions} onSelectedChange={date => alert(date)} />

and the app gives the warning you reported . can you give me a more detailed example what should i do to remove the warning ? ( if its possible )

thanks

hrahul2605 commented 3 years ago

@Unknown051 If you check the file src/datePicker/DatePicker.js

const CalendarContext = createContext();

const useCalendar = () => {
  const contextValue = useContext(CalendarContext);
  return contextValue;
};

This piece of code is causing the warnings, just moving it to different file, that will fix the warnings.