首页 > 解决方案 > 博览会常量在本机反应中不起作用

问题描述

对于状态栏而不是使用平台,我使用了 expo 常量,它工作正常突然我决定制作 expo 组件并对其进行样式设置,

export default function ExpoScreen({ Children }) {
  return <SafeAreaView style={styles.screen}>{Children}</SafeAreaView>;
}

const styles = StyleSheet.create({
  screen: {
    paddingTop: Constants.statusBarHeight,
  },
});

这是我的保存屏幕,我在其中导入 expoScreen 组件,但它没有给出任何结果,它给出了一个白屏,没有任何错误

export default function MessageScreen() {
  return (
    <ExpoScreen>
      <FlatList
        data={messages}
        keyExtractor={(message) => message.id.toString()}
        renderItem={({ item }) => (
          <ListItem
            title={item.title}
            sutitle={item.description}
            image={item.image}
          />
        )}
      />
    </ExpoScreen>
  );
}

在此处输入图像描述

标签: react-native

解决方案


您正在使用C孩子而不是孩子将其更改为

function ExpoScreen({ children }) {
  return <SafeAreaView style={styles.screen}>{children}</SafeAreaView>;
}

推荐阅读