我今天使用React Native 0.51.0开始了一个新项目,并注意到默认项目文件的类语法添加了一些新内容,<{}>语法extends Component如下:
export default class App extends Component<{}> {
...
}
Run Code Online (Sandbox Code Playgroud)
我尝试做研究,但大多数搜索引擎都会忽略特殊字符,即使是精确的字符串匹配,所以试图找出这种语法是很困难的.我做了一些测试,并且能够发现这个变化出现在v0.49.0中.该发行说明中没有提过这是什么补充语法确实,虽然.
很多模糊的关键字搜索和阅读让我相信这可能是与TypeScript相关的语法,但是对语言不熟悉,我不知道如何搜索并找出有关语法的更多信息,而不知道是什么适当的术语是.谁能告诉我语法的名称及其作用?特别是关于React Native.
我有一个用例,我想列出水平卡片.我用水平ScrollView实现了它.
然后,对于每张卡,我想实现拉动 - 刷新模式,以便更新卡中显示的数据.因此我使用RefreshControl组件作为ScrollView的属性.
问题是在iOS上,当我切换到另一张卡而不是第一张时,我看不到RefreshControl组件(参见下面的gif).
码
<ScrollView
contentContainerStyle={styles.container}
horizontal
pagingEnabled
showsHorizontalScrollIndicator={false}
directionalLockEnabled
contentInset={{top: 1}}
refreshControl={
<RefreshControl
refreshing={this.state.isRefreshing}
onRefresh={this._onRefresh.bind(this)}
/>
}
>
<Text style={styles.card}>First child</Text>
<Text style={styles.card}>Second child</Text>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
以下演示中的完整代码
演示 https://rnplay.org/apps/sRXpEw
编辑
它看起来与代码的这一部分有关:Libraries/Components/ScrollView/ScrollView.js#L523-L529
uiscrollview ios uirefreshcontrol pull-to-refresh react-native