Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InteractionManager is not working #22982

Closed
yasir-netlinks opened this issue Jan 14, 2019 · 2 comments
Closed

InteractionManager is not working #22982

yasir-netlinks opened this issue Jan 14, 2019 · 2 comments
Labels

Comments

@yasir-netlinks
Copy link

Environment

React Native Environment Info:
    System:
      OS: macOS 10.14.1
      CPU: (4) x64 Intel(R) Core(TM) i5-4288U CPU @ 2.60GHz
      Memory: 53.33 MB / 8.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.10.0 - /usr/local/bin/node
      Yarn: 1.9.4 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
      Android SDK:
        API Levels: 23, 25, 26, 27, 28
        Build Tools: 23.0.1, 25.0.1, 25.0.3, 26.0.1, 26.0.3, 27.0.3, 28.0.2, 28.0.3
        System Images: android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-26 | Google APIs Intel x86 Atom_64, android-27 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.1 AI-173.4907809
      Xcode: 10.0/10A255 - /usr/bin/xcodebuild
    npmPackages:
      react: ^16.6.3 => 16.6.3 
      react-native: ^0.57.8 => 0.57.8 
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

Description

Hi guys, as the title suggests, my code doesn't run when wrapped inside InteractionManager.runAfterInteractions. This is happening in Android but not sure about ios

e.g.

componentDidMount(){
       InteractionManager.runAfterInteractions(() => {
        this.props.navigation.setParams({
            headerRight: <SearchCount />
        });
      });
}

Similar issue is happening in other components where I wrapped few remote request to be dispatched inside InteractionManager but they do not execute at all

@bartolkaruza
Copy link

InteractionManager is working on the latest React Native version and in this snack https://snack.expo.io/@bartolkaruza/MjI5OD
We are not able to reproduce the issue, could you please check what other parts of your code could be causing the issue for you?

We've tested this on the current expo version, RN 0.57 and on the latest RN version 0.59.1

@arg1998
Copy link

arg1998 commented Jul 27, 2019

sorry for opening this issue. i have a similar problem on this topic. it seems runAfterInteractions() doesn't work in componentDidMount().

this is the code :

componentDidMount(){
    InteractionManager.runAfterInteractions(() => {
         // this doesn't work !!!
         this.scrollView.current.getNode().scrollTo({ y: 70 0, animated: false });
    });
}

and here is the actual component tree

<Animated.ScrollView
          bounces={false}
          ref={this.scrollView}
          style={StyleSheet.absoluteFill}
          showsVerticalScrollIndicator={false}
          scrollEventThrottle={16}
          onScroll={Animated.event(
            [{ nativeEvent: { contentOffset: { y: this.scrollY } } }],
            { useNativeDriver: true }
          )}
        >
          {someLongComponent}
</Animated.ScrollView>

output of react-native info :

System:
    OS: Linux 4.15 Ubuntu 18.04.2 LTS (Bionic Beaver)
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 179.70 MB / 15.54 GB
    Shell: 4.4.20 - /bin/bash
  Binaries:
    Node: 10.15.0 - ~/.nvm/versions/node/v10.15.0/bin/node
    Yarn: 1.17.3 - /usr/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.15.0/bin/npm
  SDKs:
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.1
      System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.60.4 => 0.60.4 
  npmGlobalPackages:
    react-native-cli: 2.0.1

any idea why?

Alternative Solution:

i had to wrap my code inside a setTimeout() to work this around.

@facebook facebook locked as resolved and limited conversation to collaborators Mar 19, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants