在react native中更新由RNCSafeAreaView管理的视图的属性“edges”时出错

yrdbyhpb  于 2023-08-07  发布在  React
关注(0)|答案(2)|浏览(194)

错误:"Error While Updating property "edges" of a view managed by RNCSafeAreaView"
在第一页不知何故加载没有错误,但当我重新加载它我得到这个错误。

import React from 'react'
import { SafeAreaView } from 'react-native-safe-area-context';

import SearchBar from './SearchBar';

const Homepage = ()=>{

  return (
    <SafeAreaView edges={['top']}>
        <SearchBar/>
    </SafeAreaView>
  )
}

export default Homepage;

字符串
我尝试清除缓存,将“react-native-safe-area-context”更新为最新版本,但没有任何效果

oogrdqng

oogrdqng1#

通过将“react-native-safe-area-context”库降级到版本4.0.0,问题得到解决
cmd:npm install react-native-safe-area-context@4.0.0

tkqqtvp1

tkqqtvp12#

您得到的错误是因为您试图将SafeAreaView的edges属性设置为字符串。edges属性需要一个字符串数组,因此您需要将代码更改为以下内容:

import React from 'react'
import { SafeAreaView } from 'react-native-safe-area-context';

import SearchBar from './SearchBar';

const Homepage = ()=>{

  return (
    <SafeAreaView edges={['top']}>
        <SearchBar/>
    </SafeAreaView>
  )
}

export default Homepage;

字符串
以下是讨论此问题的GitHub问题的链接:https://github.com/th3rdwave/react-native-safe-area-context/issues/190

相关问题