如何用 React Native 的 React Navigation 替换屏幕
现在我是新手,我无法理解 getStateForAction 现在我在屏幕 1 上有参数,并通过传递参数用户名导航到屏幕 2 基本导航它的嵌套屏幕 1 > 2 在堆栈上
但我需要在屏幕 2 处于活动状态后将屏幕 1 替换为屏幕 2(像路由器通量上的 ActionConst.REPLACE 一样替换)并以新方式发送参数
有人可以指导我吗谢谢。
屏幕1
onPress = () => {
this.props.navigation.navigate('Sc2', {username: this.state.username});
}
Run Code Online (Sandbox Code Playgroud)
屏幕2
componentWillMount() {
const {state} = this.props.navigation;
console.log(state.params.username);
}
Run Code Online (Sandbox Code Playgroud)
路由器
export const LoginNavStack = StackNavigator({
Sc1: {
screen: Sc1
},
Sc2: {
screen: Sc2,
},
});
Run Code Online (Sandbox Code Playgroud) <Button
onPress={{() => Alert.alert(
'Alert Title',
'alertMessage',
[
{text: 'Cancel', onPress: () => console.log('Cancel Pressed!')},
{text: 'OK', onPress: () => {this.onDeleteBTN}},
],
{ cancelable: false }
)}}
>
<Text> Delete Record </Text>
</Button>
Run Code Online (Sandbox Code Playgroud)
在Alert Dialog上按OK按钮后我需要打电话
onDeleteBTN = () => {
alert(' OnDelete');
}
Run Code Online (Sandbox Code Playgroud)
{text: 'OK', onPress: () => {this.onDeleteBTN.bind(this)}},
{text: 'OK', onPress: () => {this.onDeleteBTN}},
Run Code Online (Sandbox Code Playgroud)
这不行
javascript reactjs react-native react-native-android react-native-ios
当我使用填充样式时出现的问题是 Android - iOS 上的差异
<Content style={{padding: '7%'}}>
Run Code Online (Sandbox Code Playgroud)
我怎样才能把它穿成同样的风格

如果我有这样的json
{
title: "The Basics - Networking",
description: "Your app fetched this from a remote endpoint!",
movies: [
{
title: "Star Wars",
category: "space",
releaseYear: "1977"
},
{
title: "Back to the Future",
category: "time"
releaseYear: "1985"
},
{
title: "The Matrix",
category: "scifi",
releaseYear: "1999"
},
{
title: "Inception",
category: "fantasy",
releaseYear: "2010"
},
{
title: "Interstellar",
category: "space"
releaseYear: "2014"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我需要过滤category = space的一些数据 但我不知道如何在获取json表单webservice之后过滤数据
我只想要数据形式category = space (这意味着我想得到星际和星球大战)
并设置为数据源像"dataSource:ds.cloneWithRows(responseJson.movies)"但这个方法得到所有行没有过滤器
componentDidMount() { …Run Code Online (Sandbox Code Playgroud)