首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >React.Children.map中缺少map属性

React.Children.map中缺少map属性
EN

Stack Overflow用户
提问于 2018-05-04 12:00:56
回答 1查看 675关注 0票数 0

可刷卡:

代码语言:javascript
复制
render() {
  const {
    children, containerStyle, revealContainerStyle, rightSwipeContent,
  } = this.props;

const swipeAnimStyle = {
  right: this.swipeAnim,
};

const childrenWithProps = React.Children.map(children, child => React.cloneElement(child, {
  swipeLeftPanResponder: this.swipeLeftPanResponder,
}));

return (
  <View style={[styles.container, containerStyle]}>
    <Animated.View style={[styles.swipedSection, swipeAnimStyle]}>
      {childrenWithProps}
    </Animated.View>

    <View
      style={[styles.revealedContainer, revealContainerStyle]}
    >
      {rightSwipeContent()}
    </View>
  </View>
);
}

正在使用上述组件,如下所示:

代码语言:javascript
复制
renderStory({ item }: Object) {
  const story = this.props.feeds.byId[item];

return (
  <SwipeableCard
    key={item}
    containerStyle={styles.feedCard}
    rightSwipeContent={this.renderSwipeContent(story, this.props.portfolios)}
  >
    <StoryCard story={story} onStoryPress={this.onStoryPress(item)} />
  </SwipeableCard>
);
}

.flowconfig.js

代码语言:javascript
复制
[ignore]
; We fork some components by platform
.*/*[.]android.js

; Ignore React Navigation
.*/node_modules/react-navigation/.*

; Ignore React Native Tab View
.*/node_modules/react-native-tab-view/.*

; Ignore React Native Loading Placeholder
.*/node_modules/react-native-loading-placeholder/.*

; Ignore React Native Linear Gradient
.*/node_modules/react-native-linear-gradient/.*

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*

; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js

; Ignore polyfills
.*/Libraries/polyfills/.*

; Ignore React Native
<PROJECT_ROOT>/node_modules/react-native/.*
<PROJECT_ROOT>/node_modules/expo/.*

; Ignore project JSON files
<PROJECT_ROOT>/tools/resources/.*

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow/
node_modules/expo/flow/
flow-typed

[options]
emoji=true

module.file_ext=.css
module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json

module.system=haste

munge_underscores=true

module.name_mapper='^src' -> '<PROJECT_ROOT>/src'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
module.name_mapper='^react-navigation$' -> 'emptyObject'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-3]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-3]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

我收到下面为代码提供的流错误消息:

无法调用React.Children.map,因为属性mapChildren中丢失

"flow-bin":"^0.71.0“

“流类型”:"^2.4.0",

“反应”:"16.2.0",

“反应-原生”:"https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz",

EN

回答 1

Stack Overflow用户

发布于 2018-05-10 08:31:29

它对我来说很好,而且是在React的类型定义中。这是一个尝试链接。我敢打赌,在本地和全球版本的flow之间肯定存在差异,而且您正在运行一个过时的版本:

代码语言:javascript
复制
yarn upgrade flow@0.70
./node_modules/.bin/flow

这样可以运行本地版本(或者在package.json中定义任务)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50174456

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档