从 Expo 添加 Facebook 广告时,React Native 按钮不起作用

React Native Buttons don't work when adding FacebookAds from Expo

我的 React Native 应用程序有问题。每次我添加来自 expo<Facebook.BannerView /> 组件时,来自 react-native-elements<Button /> 组件停止工作。

示例:

我的按钮在这个实现中工作正常:

render() {
  const { containerStyle, adContainerStyle } = styles;

  return (
    <View style={{ flex: 1 }}>
      <View style={containerStyle}>

        <Button
          title="Button"
          onPress={() => console.log('Button pressed')}
        />
      </View>
      <View style={adContainerStyle}>
        <Text>Bottom Banner Ad goes here</Text>
      </View>
    </View>
  );
}

const styles = {
  containerStyle: {
    flex: 1,
    justifyContent: 'space-around',
    alignItems: 'center',
    backgroundColor: '#ddd'
  },
  adContainerStyle: {
    height: 50,
    backgroundColor: '#ccc',
    width: SCREEN_WIDTH,
    justifyContent: 'center',
    alignItems: 'center'
  }
};

但是当我用这个替换我的 <Text>Bottom Banner Ad goes here</Text> 组件时:

<FacebookAds.BannerView
  placementId="328225604270934_328227207604107"
  type="standard"
  onPress={() => console.log('Banner ad clicked')}
  onError={err => console.log('Banner Ad Error', err)}
/>

<Button /> 停止工作。

知道如何解决这个问题吗?

我发现 adContainerStyleFacebook.BannerView /> 组件冲突。

我通过从 adContainerStyle 中删除除 backgroundColor 属性之外的所有样式属性解决了我的问题,如下所示:

adContainerStyle: {
    backgroundColor: '#ccc',
}

编辑:

我意识到这是一个反复出现的问题。出于某种原因,删除 <Facebook.BannerView /> 组件,运行 应用程序(因此它可以工作)然后每次都将组件添加回固定它。

有点烦人,希望它能很快自行修复,但这是目前合适的解决方法。