React-native-code-push: Blank screen react-native-navigation

Created on 16 May 2017  路  1Comment  路  Source: microsoft/react-native-code-push

Thanks so much for filing an issue or feature request! Please fill out the following (wherever relevant):

Description

[FILL THIS OUT: Explain what you did, what you expected to happen, and what actually happens. Also exact reproduction steps and stack trace will be much appreciated.]
When used with react-native-router-flux everything is updated just fine.
However when used with react-native-navigation, the app just renders a blank screen with nothing on a screen ( no navbar and no tabbar )
Here is my index.ios.js

import { StatusBar } from 'react-native'
import App from './src'

StatusBar.setHidden(true,'slide')
const app = new App();

Here is my src/index.js

import { iconsMap, iconsLoaded } from '@lib/AppIcons';


import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TouchableOpacity,
  Platform,
  Animated,
} from 'react-native';

import { Navigation } from 'react-native-navigation';
import { registerScreens } from './screens';


const navigatorStyle = {
  navBarTranslucent: true,
  drawUnderNavBar: true,
  navBarTextColor: 'white',
  navBarButtonColor: 'white',
  statusBarTextColorScheme: 'light',
  statusBarHidden: true,
  drawUnderTabBar: true
};



class App extends Component {

  constructor(props) {
    super(props);
    const store = configureStore(getInitialState());
    registerScreens(store, Provider);

    store.dispatch(setStore(store))
    iconsLoaded.then(() => { 
     if (!__DEV__)
      codePush.sync({
        updateDialog: true,
        installMode: codePush.InstallMode.ON_NEXT_RESUME
      });
      this.startApp();
    });
  }

  startApp() {
    Navigation.startTabBasedApp({
      tabs: [
        {
          label: 'Test',
          screen: 'app.DebugContainer',
          icon: iconsMap['ios-beer'],
          selectedIcon: iconsMap['ios-beer'],
          title: 'Test',
          navigatorStyle,

        },
        {
          label: 'Test2',
          screen: 'app.DebugContainer',
          icon: iconsMap['ios-beer'],
          selectedIcon: iconsMap['ios-beer'],
          title: 'Test2',
          navigatorStyle
        }
      ],
      tabsStyle: {
        tabBarButtonColor: AppConfig.defaultTextColor,
        tabBarSelectedButtonColor: AppConfig.selectedTextColor,
        tabBarBackgroundColor: AppConfig.tabBarBackgroundColor,
      }
    });
  }

}

App = codePush({ checkFrequency: codePush.CheckFrequency.MANUAL })(App);

export default App;

Here is my screens.js

import DebugContainer from '@containers/DebugContainer'
export function registerScreens(store, Provider) {
    Navigation.registerComponent('app.DebugContainer', () => DebugContainer, store, Provider);
   }

Here is my AppDelegate.m

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

#import "AppDelegate.h"
#import <CodePush/CodePush.h>

#import <asl.h>
#import <React/RCTLog.h>

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

#import <React/RCTLinkingManager.h>

// **********************************************
// *** DON'T MISS: THE NEXT LINE IS IMPORTANT ***
// **********************************************
#import "RCCManager.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;


#ifdef DEBUG
    jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
#else
    jsCodeLocation = [CodePush bundleURL];
#endif

  // **********************************************
  // *** DON'T MISS: THIS IS HOW WE BOOTSTRAP *****
  // **********************************************
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  self.window.backgroundColor = [UIColor whiteColor];
  [[RCCManager sharedInstance] initBridgeWithBundleURL:jsCodeLocation];

  /*
  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"packagename"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];

  rootView.backgroundColor = [UIColor blackColor];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  */
  return YES;
  }

if I remove App = codePush({ checkFrequency: codePush.CheckFrequency.MANUAL })(App);
it renders just fine, but obviously the app doesnt get updated.

Reproduction

[FILL THIS OUT: If possible try to reproduce your bug on our basic sample: https://github.com/Microsoft/react-native-code-push/tree/master/Examples/CodePushDemoApp. If you can't reproduce the bug on it, provide us as much info as possible about your project.]

react-native init projectname
yarn add react-native-code-push (install by following the official guide)
yarn add react-native-navigation (install by following the official guide)
react-native run-ios

Additional Information

  • react-native-code-push version: 2.0.3-beta
  • react-native version: 0.44.0
  • iOS/Android/Windows version: 10.3/7.0.0
  • Does this reproduce on a debug build or release build? Both
  • Does this reproduce on a simulator, or only on a physical device? Both

(The more info the faster we will be able to address it!)

Most helpful comment

Alright figured it out.
Instead of App = codePush({ checkFrequency: codePush.CheckFrequency.MANUAL })(App);
I did
App = codePush({ checkFrequency: codePush.CheckFrequency.MANUAL })(new App());
For some unknown reasons I forgot to count on that constructor.

Thank you for your attention.

>All comments

Alright figured it out.
Instead of App = codePush({ checkFrequency: codePush.CheckFrequency.MANUAL })(App);
I did
App = codePush({ checkFrequency: codePush.CheckFrequency.MANUAL })(new App());
For some unknown reasons I forgot to count on that constructor.

Thank you for your attention.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ACCTFORGH picture ACCTFORGH  路  3Comments

sergey-akhalkov picture sergey-akhalkov  路  4Comments

EdmundMai picture EdmundMai  路  4Comments

quanzaiyu picture quanzaiyu  路  3Comments

Adr1ann picture Adr1ann  路  3Comments