React Native,无法更新值

我正在尝试更新 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 });

  };

有人可以帮我吗...


Smart猫小萌
浏览 99回答 1
1回答

莫回无

你有错字,无论如何你为什么不使用 useState 呢?<AppTextInput&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; value={this.props.navigation.getParam("title")}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conChangeText={(text) => --> typo, should be onChangeText ?&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.props.navigation.setParams({ title: text })&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }/>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript