我正在尝试更新 title 的值但它没有更新值有人可以告诉我 EditPost.js 上发生了什么class EditScreen extends Component { render() { return ( <KeyboardAvoidingView behavior="position" keyboardVerticalOffset={Platform.OS === "ios" ? 0 : 100} > <Image style={styles.image} source={this.props.navigation.getParam("image")} /> <View style={styles.detailContainer}> <AppTextInput value={this.props.navigation.getParam("title")} conChangeText={(text) => this.props.navigation.setParams({ title: text }) } /> <AppTextInput value={this.props.navigation.getParam("des")} /> </View> <AppButton text="Save" style={styles.button} onPress={() => { this.props.navigation.getParam("onEdit"); this.props.navigation.goBack(); }} />主页.js onEdit = (data) => { const newPosts = this.state.post.map((item) => { if (item.key === data.key) return data; else return item; }); this.setState({ post: newPosts, editMode: false }); };有人可以帮我吗...
1 回答
莫回无
TA贡献1865条经验 获得超7个赞
你有错字,无论如何你为什么不使用 useState 呢?
<AppTextInput
value={this.props.navigation.getParam("title")}
conChangeText={(text) => --> typo, should be onChangeText ?
this.props.navigation.setParams({ title: text })
}
/>
添加回答
举报
0/150
提交
取消