react-native-modern-datepicker icon indicating copy to clipboard operation
react-native-modern-datepicker copied to clipboard

require cycle warnings

Open hrahul2605 opened this issue 4 years ago • 4 comments

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?

hrahul2605 avatar Jul 10 '20 06:07 hrahul2605

Hi . any plan to fix the warning ?

salarihamid avatar Dec 17 '20 12:12 salarihamid

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

hrahul2605 avatar Dec 17 '20 12:12 hrahul2605

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

salarihamid avatar Dec 17 '20 15:12 salarihamid

@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.

hrahul2605 avatar Dec 18 '20 07:12 hrahul2605