如果针对特定页面关闭了远程调试JS,则模拟器上的应用程序崩溃

时间:2018-01-12 17:13:06

标签: javascript android reactjs react-native react-native-router-flux

这是非常令人惊讶的,我不知道为什么会这样。但我可能会对组件产生影响。 我正在使用react-native-router-flux库进行导航。在以下代码中,我使用drawerIcon prop defined here来更改默认的汉堡图标:

<Scene key="eng"
          drawer
          drawerIcon={<MenuButton />}
          drawerWidth={250}
          hideNavBar
          contentComponent={MenuContent}
        >
          <Scene key="home" component={Home} hideNavBar={false} title="Home" initial />
          ...
          <Scene key="weekOffer" component={WeekOffer} hideNavBar={false} title="Deal of the Week!" />

当我远程启用Debug JS时,按下汉堡包抽屉会打开抽屉,然后当我使用关键字weekOffer按下场景时,它工作得很好!但是,当我关闭远程调试时,相同的事件序列(按下具有键weekOffer的场景)会使我的应用程序崩溃!!

任何其他场景都不会发生......

我的菜单按钮组件如下所示:

class MenuButton extends Component {
  render() {
    return (
      <View style={{ justifyContent: 'center', alignItems: 'center', height: 35, width: 40, }}>
        <View style={styles.iconContainerStyle}>
          <Icon name='menu' size={23} style={styles.iconStyle} />
        </View>
      </View>
    );
  }
}

最后我的weekOffer组件如下所示:

class weekOffer extends Component {
  constructor(props) {
    super(props);
    console.log(props);
    this.id = null;
    this.ref = firebase.firestore().collection('WeeklyOffer').doc('offer');
    this.state = {
      paused: false,
      phone: null,
      loading: true
    };
  }
  componentWillMount() {
    this.ref.get().then(doc => {
      const docObject = doc.data();
      const docObjectId = Object.assign({}, docObject, { id: doc.id });
      console.log(docObjectId);
      this.setState(
        docObjectId,
        );
      console.log(this.state);
    })
    .catch(err => {
        console.log('Error getting documents', err);
    });
  }


  render() {
  ...
    return (
  <View style={{ flex: 1 }}>
    <TouchableOpacity
      style={styles.infoStyle}
      onPress={() => {
        if (this.props.language === 'arab') { Actions.comDetailsAr(this.state); }
        else { Actions.comDetails(this.state); }
        }
      }
    >
      <Text />
      <Text style={styles.textStyle}> {lang[this.props.language].about} </Text>
      <Icon name='info-with-circle' size={40} style={{ color: '#ffffff' }} />
    </TouchableOpacity>

    <TouchableOpacity
      style={styles.imageContainerStyle}
      onPress={() => this.setState({ paused: !this.state.paused })}
    >
      <Video
        source={{ uri: this.state.offer }}
        rate={1.0}                   // 0 is paused, 1 is normal.
        volume={1.0}                 // 0 is muted, 1 is normal.
        muted={false}                // Mutes the audio entirely.
        paused={this.state.paused}               // Pauses playback entirely.
        resizeMode="contain"           // Fill the whole screen at aspect ratio.
        repeat                       // Repeat forever.
        onLoadStart={this.loadStart} // Callback when video starts to load
        onLoad={this.setDuration}    // Callback when video loads
        onError={this.videoError}    // Callback when video cannot be loaded
        style={styles.backgroundVideo}
      />
    </TouchableOpacity>

    <FooterSharing
      phone={this.state.phone}
      offerLink={this.state.offer}
      id={this.state.id}
    />
  </View>
);
  }
}



export default weekOffer;

有没有人知道为什么如果远程调试js关闭模拟器上的应用程序会崩溃?

0 个答案:

没有答案