我在 iOS 上收到以下错误作为可消除的错误。 (按 esc 按钮隐藏错误并显示我的应用程序。)
Invalid YGDirection 'row' should be one of: (inherit, ltr, rtl) - React Native
我正在使用 styled components在我的项目中,但我认为这个错误不是由组件引起的。
由于 react-native 使用 flex 布局,我们应该可以使用
flex-direction
属性。我的包装组件如下:
const Wrapper = styled.View`
flex: 1;
align-items: ${props => props.align};
justify-content: ${props => props.justify};
flex-direction: ${props => props.direction};
flex-grow: ${props => props.grow};
flex-shrink: ${props => props.shrink};
`;
Wrapper.defaultProps = {
direction: 'column',
align: 'flex-start',
justify: 'flex-start',
grow: 1,
shrink: 0,
};
我错过了什么吗?
完整的错误如下所示:
最佳答案
我遇到了同样的问题并在几个小时后解决了它。
搜索任何带有方向属性的 Text 组件。<Text direction={value} />
将其更改为<Text dir={value} />
或任何你喜欢的 Prop 名称
根据您的代码,它将在您的 Wrapper 中,并带有 Prop 名称方向。
关于react-native - 无效的 YGDirection 'row' 应该是 : (inherit, ltr, rtl) 之一 - React Native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60479653/