私は、Text-FieldのMaterial-ui react jsコンポーネントです。私はredux形式を使用していません。ReactJS - this.props.reducer.result.firstNameからのデータをバインドした後に入力フィールドを編集できません。
私は状態だけでなく、私は減速機能を介して、小道具から受け取った値を用いて、入力要素の値を更新するかどうかはわかりませんのonchange listernerと状態
constructor(props) {
super(props);
this.state = {
firstName: null,
};
this.handleInputChange = this.handleInputChange.bind(this);
}
componentDidMount() {
// This is reducer function to get my data from server. I'm getting data and able to display it to my element.
// I'm using redux for my data layer.
this.props.getuserDetails(userId);
}
を宣言しました。
handleInputChange (event) {}
this.setState({
firstName: event.target.value
});
}
my render関数内。 テキストフィールドには、ユーザーのfirstnameが表示されます。しかし、私はフィールドを編集することができません。私はprops.reducerを直接バインドしているからです。
<TextField name="firstName" onChange={this.handleInputChange} floatingLabelText="First Name" value={this.props.reducer.result.firstName}/>
は、どのように私は、ディスパッチャ/減速からデータをバインドします。また、ユーザー入力を受け入れて名を編集します。 後でサーバーで更新できます
私はこの問題を抱えています。どんな助けもありがとう。ありがとう。
ありがとうございます。出来た。以前は、以下のメソッドで状態値を設定しようとしましたが、失敗しました。componentWillReceiveProps(){] – PremPalanisamy