gpt4 book ai didi

React-Native View 以显式设置的宽度/高度呈现,但 flexBasis 为 0

转载 作者:行者123 更新时间:2023-12-03 14:45:02 25 4
gpt4 key购买 nike

在 React-native 0.39 中,

我经常收到这个错误,但我真的不明白为什么(显然我没有设置 flexGrow ......)。

这是来自控制台的错误

View was rendered with explicitly set width/height but with a 0 flexBasis. (This might be fixed by changing flex: to flexGrow:) View: <RCTShadowView: 0x6080005a02a0; viewName: RCTView; reactTag: 2608; frame: {{0, 0}, {nan, nan}}>

有人可以向我解释为什么会触发此错误吗?

编辑 :错误来自我在主 View 中添加的这段样板代码:
flex: 1,
// remove width and height to override fixed static size
width: null,
height: null,

但是,如果有人可以阐明 react-native 样式或引导我找到好的资源,我将不胜感激 :)

最佳答案

引用 react-native/React/Views/RCTShadowView.m ,有评论

    This works around a breaking change in css-layout where setting flexBasis needs to 
be set explicitly, instead of relying on flex to propagate.

We check for it by seeing if a width/height is provided along with a flexBasis
of 0 and the width/height is laid out as 0.

时触发错误没有定义 flexBasis 且宽度和高度为零的 flex .

引用 react-native/Libraries/StyleSheet/LayoutPropTypes.js ,我们知道 flexGrow、flexShrink 和 flexBasis 接收数字值。

有关视觉指南,您可以引用此网页, A Visual Guide to CSS3 Flexbox Properties .

关于React-Native View 以显式设置的宽度/高度呈现,但 flexBasis 为 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41004883/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com