2017-11-25 10 views
1

私は別のページからリダイレクトしている次のページに複数の状態を渡したいと思います。ReactJSのリンクで複数の状態を渡す方法

私はすでに通り過ぎており、それはうまくいきます。

<Link to ={{pathname: "/CreateEventUser", state: { bucket_id: !this.state.selected_bucket.id ? this.state.recent_bucket : this.state.selected_bucket } }} > 
<button type="button" className="btn btn-danger">Create an Event</button> 
</Link> 

今は2つの状態を渡す必要があります。その構文は何ですか?

<Link to ={{pathname: "/EventDetailsUser", state: { bucket_id: !this.state.selected_bucket.id ? this.state.recent_bucket : this.state.selected_bucket, eventId: event.id}}} > 

答えて

1

場所のパス名exceptsでとオブジェクト内のstateパラメータとあなたが必要として、したがって、あなたが

<Link to ={{ 
    pathname: "/CreateEventUser", 
    state: { 
     bucket_id: !this.state.selected_bucket.id ? this.state.recent_bucket : this.state.selected_bucket, 
     new_id: this.state.newID, 
     anotherValue: this.state.anotherValue 
    } 
    }} > 
<button type="button" className="btn btn-danger">Create an Event</button> 
</Link> 
+0

のようなオブジェクトのように渡すことで、できるだけ多くの値を渡すことができありがとう...... –

関連する問題