Flowjs: свойство карты отсутствует в React.Children.map - PullRequest
0 голосов
/ 04 мая 2018

перелистываемой-card.js:

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>
);
}

Вышеуказанный компонент используется, как показано ниже:

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

[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, так как свойство map отсутствует в Children

"flow-bin": "^ 0.71.0",

"типизированный поток": "^ 2.4.0",

«реагировать»: «16.2.0»,

"реагировать-нативный": "https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz",

1 Ответ

0 голосов
/ 10 мая 2018

У меня работает нормально, и это в определении типа для React . Вот вам Попробуйте ссылку . Держу пари, что существует несоответствие между локальной и глобальной версией потока, и вы используете устаревшую версию:

yarn upgrade flow@0.70
./node_modules/.bin/flow

Это должно работать для запуска локальной версии (или определения задачи внутри вашей package.json).

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...