Skip to content

Commit

Permalink
fix: resolve Require Cycle warning (#27851)
Browse files Browse the repository at this point in the history
Summary:
When I was testing React Native 0.62-rc.1, I noticed that console was showing a warning for Require Cycle as shown in image below

![Screen Shot 2020-01-24 at 12 22 38](https://user-images.githubusercontent.com/6936373/73042467-998dff00-3ea4-11ea-911c-955d55fd0743.png)

This is because ScrollResponder was importing `ScrollView` to get the `typeof ScrollView`.
I've made an export for ScrollView type in `ScrollView` so that Require cycle warning will not show up.

## Changelog

[General] [Fixed] - Remove Require cycle warning.
Pull Request resolved: #27851

Differential Revision: D19577644

Pulled By: cpojer

fbshipit-source-id: 257b9421a91244d69394375102cfbe683326bba2
  • Loading branch information
Naturalclar authored and facebook-github-bot committed Jan 27, 2020
1 parent 56dfc86 commit 674ac69
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Libraries/Components/ScrollResponder.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ const ReactNative = require('../Renderer/shims/ReactNative');
const TextInputState = require('./TextInput/TextInputState');
const UIManager = require('../ReactNative/UIManager');
const Platform = require('../Utilities/Platform');
const ScrollView = require('./ScrollView/ScrollView');
import Commands from './ScrollView/ScrollViewCommands';

const invariant = require('invariant');
const performanceNow = require('fbjs/lib/performanceNow');

import type {PressEvent, ScrollEvent} from '../Types/CoreEventTypes';
import typeof ScrollView from './ScrollView/ScrollView';
import type {Props as ScrollViewProps} from './ScrollView/ScrollView';
import type {KeyboardEvent} from './Keyboard/Keyboard';
import type EmitterSubscription from '../vendor/emitter/EmitterSubscription';
Expand Down Expand Up @@ -468,7 +468,7 @@ const ScrollResponderMixin = {
({x, y, animated} = x || {});
}

const that: React.ElementRef<typeof ScrollView> = (this: any);
const that: React.ElementRef<ScrollView> = (this: any);
invariant(
that.getNativeScrollRef != null,
'Expected scrollTo to be called on a scrollViewRef. If this exception occurs it is likely a bug in React Native',
Expand All @@ -492,7 +492,7 @@ const ScrollResponderMixin = {
// Default to true
const animated = (options && options.animated) !== false;

const that: React.ElementRef<typeof ScrollView> = (this: any);
const that: React.ElementRef<ScrollView> = (this: any);
invariant(
that.getNativeScrollRef != null,
'Expected scrollToEnd to be called on a scrollViewRef. If this exception occurs it is likely a bug in React Native',
Expand Down Expand Up @@ -531,7 +531,7 @@ const ScrollResponderMixin = {
);
}

const that: React.ElementRef<typeof ScrollView> = this;
const that: React.ElementRef<ScrollView> = this;
invariant(
that.getNativeScrollRef != null,
'Expected zoomToRect to be called on a scrollViewRef. If this exception occurs it is likely a bug in React Native',
Expand All @@ -547,7 +547,7 @@ const ScrollResponderMixin = {
* Displays the scroll indicators momentarily.
*/
scrollResponderFlashScrollIndicators: function() {
const that: React.ElementRef<typeof ScrollView> = (this: any);
const that: React.ElementRef<ScrollView> = (this: any);
invariant(
that.getNativeScrollRef != null,
'Expected flashScrollIndicators to be called on a scrollViewRef. If this exception occurs it is likely a bug in React Native',
Expand Down

0 comments on commit 674ac69

Please sign in to comment.