无效的 YGDirection 'row' 应该是以下之一:(inherit, ltr, rtl) - React Native

R. *_*kan 3 react-native react-native-ios

我在 iOS 上收到以下错误作为可消除的错误。(按 esc 按钮隐藏错误并显示我的应用程序。)

无效的 YGDirection 'row' 应该是以下之一:(inherit, ltr, rtl) - React Native

我在我的项目中使用样式组件,但我认为这个错误不是由组件引起的。

由于 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,
};
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?完整的错误如下所示: 在此处输入图片说明

小智 6

我遇到了同样的问题并在几个小时后解决了它。

搜索任何带有方向属性的 Text 组件。
<Text direction={value} />
将其更改为
<Text dir={value} /> 您喜欢的任何道具名称

根据您的代码,它将在您的 Wrapper 中,并带有道具名称方向。

  • React Native 团队确实应该有更好的错误消息...... (2认同)