【问题标题】:react-native-navigation showInAppNotification blankreact-native-navigation showInAppNotification 空白
【发布时间】:2017-09-20 10:08:00
【问题描述】:

尝试使用 this.props.navigator.showInAppNotification

this.props.navigator.showInAppNotification({
  screen: "example.InAppNotification", 
  passProps: {
    title: 'Title',
    body: 'Body...'
  }, 
  position: 'bottom',
  autoDismissTimerSec: 3
});

屏幕 InAppNotification 已注册,但看到通知内容为空白:

有人可以帮忙吗?

example.InAppNotification:

export default class InAppNotification extends Component {
  render() {
    console.log(this.props);
    return (
      <View>
        <Text>
          {JSON.stringify(this.props)}
        </Text>
      </View>
    );
  }
}

【问题讨论】:

  • 内容是什么。 example.InAppNotification
  • 将其添加到问题中。

标签: android react-native react-native-navigation


【解决方案1】:

尝试将flex:1 添加到容器View

export default class InAppNotification extends Component {
  render() {
  console.log(this.props);
  return (
    <View style={{ flex: 1 }}>
      <Text>
        {JSON.stringify(this.props)}
      </Text>
    </View>
  );
 }
}

您还需要正确注册 InAppNotification 屏幕

【讨论】:

  • 没有任何改变。我也没有在开发工具中看到 console.log。
  • 您注册了 InAppNotification 屏幕吗?
  • Navigation.registerComponent('cabinetmobile.InAppNotification', () =&gt; WrongComponent, store, Provider);WrongComponent 而不是 InAppNotification。感谢您的帮助!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-10-24
  • 1970-01-01
  • 2022-08-17
  • 1970-01-01
  • 2022-10-25
  • 2017-10-11
  • 2019-06-25
相关资源
最近更新 更多