React-native-gesture-handler: Require cycle warnings.

Created on 1 Oct 2018  路  17Comments  路  Source: software-mansion/react-native-gesture-handler

With new metro and RN 0.57, new warnings appear with Require cycle warnings.

Warning:

Require cycle: node_modules/react-native-gesture-handler/GestureHandler.js -> node_modules/react-native-gesture-handler/Swipeable.js -> node_modules/react-native-gesture-handler/GestureHandler.js

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

Where this happens:

  • [x] [GestureHandler](https://github.com/kmagiera/react-native-gesture-handler/blob/master/GestureHandler.js#L25)
  • [x] [Swipeable](https://github.com/kmagiera/react-native-gesture-handler/blob/master/Swipeable.js)
  • [x] [DrawerLayout](https://github.com/kmagiera/react-native-gesture-handler/blob/master/DrawerLayout.js)

Most helpful comment

Changing the import code in DrawerLayout.js back to:

import {
  PanGestureHandler,
  TapGestureHandler,
  State,
} from './GestureHandler';

resolves the problem

All 17 comments

Thanks for reporting @dsznajder we will look into it some time this week

@dsznajder @kmagiera It's not related to RNGH, but it's more Metro-related issue, will be sorted out if this issue will be resolved - https://github.com/facebook/metro/issues/287

Closed by #323

FYI, with v1.0.9 I'm still seeing some require cycle warnings:

Require cycle: node_modules/react-native-gesture-handler/index.js -> node_modules/react-native-gesture-handler/Swipeable.js -> node_modules/react-native-gesture-handler/index.js
require.js:109
Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
Require cycle: node_modules/react-native-gesture-handler/index.js -> node_modules/react-native-gesture-handler/DrawerLayout.js -> node_modules/react-native-gesture-handler/index.js
require.js:109
Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle

@kmagiera Should I reopen this issue to track those leave it to metro?

Facing the same issue here too. I have not found a working solution yet.

Yes. I'm reopening this issue. We should perhaps change imports in DrawerLayout and Swipeable to load from ./GestureHandler module instead of using react-native-gesture-handler. Anyone would like to submit a PR?

I hope I will find time this week and do it :)

If someone would like to handle this, just take it.

Any chance we could get a patch release to fix this? 馃槃

Thanks @kmagiera!

Hey guys! I'm still seeing the warnings on 1.0.12.

Me too. Using RNGH-1.0.12, RN-0.57.8

In DrawerLayout.js, I see:

import {
  PanGestureHandler,
  TapGestureHandler,
  State,
} from 'react-native-gesture-handler';

So it looks like something reverted the change there...

Changing the import code in DrawerLayout.js back to:

import {
  PanGestureHandler,
  TapGestureHandler,
  State,
} from './GestureHandler';

resolves the problem

@brentvatne @kmagiera Can you guys check the import regression ?

Was this page helpful?
0 / 5 - 0 ratings