2017-11-25 9 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> 

이제 두 가지 상태를 전달해야합니다. 그 문법은 무엇입니까?

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

답변

1

state 위치 경로 이름 excepts와 객체의 매개 변수 및

<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

같은 개체로 다음 전달하여 필요에 따라 따라서 당신은 많은 가치를 전달할 수는 ...... 감사합니다 –