react-navigation-switch-transitioner icon indicating copy to clipboard operation
react-navigation-switch-transitioner copied to clipboard

Native module cannot be null

Open lorenzozanotto opened this issue 6 years ago • 5 comments

After having followed the installation guide, linked the react-native-reanimated dependency and rebuilt the project, I get an error message saying "Native module cannot be null".

I'm creating a switch navigator with the react-navigation-switch-transitioner's createSwitchNavigator as follows. Is there a way to make this work?

import { createSwitchNavigator, withFadeTransition } from 'react-navigation-switch-transitioner';
import barNavigator from "./barNavigator";

export default createSwitchNavigator(
  {
    Main: withFadeTransition(barNavigator)
  }
);

simulator screen shot - iphone x - 2019-01-30 at 16 03 02

lorenzozanotto avatar Jan 30 '19 15:01 lorenzozanotto

Since version 0.1 you need to wrap the main navigator in a createAppContainer call AppContainers

This is because since react-navigation v3 that is the recommended default.

Note: In v2 and earlier, the containers in React Navigation are automatically provided by the create*Navigator functions. As of v3, you are required to use the container directly. In v3 we also renamed createNavigationContainer to createAppContainer.

If you're using an older version of react-navigation, you can call createContainedSwitchNavigator to have the container be created automatically if you're using it as a top level navigator.

Other than that, I've not seen your error before, but I've found sometimes that after recompiling is also a good thing to clear the metro cache, restart watchman with delete all, and delete all temporary files.

elyalvarado avatar Jan 30 '19 19:01 elyalvarado

@elyalvarado thank you for the prompt response. Anyways I'm already wrapping the main navigator using the createAppContainer function. In fact all the navigation hierarchy works flawlessly with react-navigation 3. All the file caches have been deleted as well. I'll investigate tomorrow and report back.

lorenzozanotto avatar Jan 30 '19 20:01 lorenzozanotto

@lorenzozanotto Were you able to solve it? I am having the same issue.

geekdevs avatar Feb 10 '19 08:02 geekdevs

@lorenzozanotto Were you able to solve it? I am having the same issue.

I have not, so I decided to switch to a custom solution. Anyway, since this library depends on react-native-reanimated I would try to install it via manual linking the iOS and Android projects and without using the react-native link command.

@elyalvarado please note that no information on react-native-reanimated dependency is stated in the readme, hence no instruction on how to configure it properly.

lorenzozanotto avatar Feb 12 '19 11:02 lorenzozanotto

This fork fixes the issue.

LuisRodriguezLD avatar Feb 23 '19 23:02 LuisRodriguezLD