このようにコンストラクターで自分の状態を定義しています。
constructor(props) {
super(props);
this.state = {
order: props.data ? { ...props.data } : { title: '', birthdate: '' , gender: '', startdate: '', starttime: '', brand: null},
次に、別の関数で、order.brandのみにsetStateを設定しようとしています
this.setState({
//order: { brand: items[0].title },
order: { ...order, brand: items[0].title },
});
コメント行はすべての要素を上書きしており、2 番目はその順序が定義されていないことを返します。
複数の値を持つ状態の 1 つの項目だけを保存する正しい構文は何ですか。