And*_*zon 6 reactjs flowtype react-native
我正在尝试重现Flow文档中有关指定子prop的元素类型的步骤.这个例子是关于官方文档的.
我目前正在反应原生环境中测试它,使用:
我正在测试的代码是:
// @flow
import * as React from 'react'
import { StyleSheet, View, Text } from 'react-native'
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
})
const Item = () => <Text>Item</Text>
type Props = {
children: React.ChildrenArray<React.Element<typeof Item>>,
}
const Container = (props: Props) => <View>{props.children}</View>
export default () => (
<View style={styles.container}>
<Container>
<Item />
<View />
</Container>
</View>
)
Run Code Online (Sandbox Code Playgroud)
预期的行为:从流中获取错误,因为我在View组件内部使用了一个Container组件,但我没有收到任何错误.
我也尝试过在try flow网站上只使用React的等效版本,但我也没有收到来自流程的错误:
/* @flow */
import * as React from 'react'
const Item = () => <span>Item</span>
type Props = {
children: React.ChildrenArray<React.Element<typeof Item>>,
}
const Container = (props: Props) => <div>{props.children}</div>
export default () => (
<div>
<Container>
<Item />
<Item />
<span>Text</span>
</Container>
</div>
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
414 次 |
| 最近记录: |