React.js

react 페이지 이동시 파라미터 전달

yongary 2019. 7. 22. 09:00

 

1. URL 방식으로 파라미터 전달

 

보내는 쪽에선

url = 'buy.js?order=' + JSON.stringify(order) 로 보내고

 

받는 쪽에선  

const params = new URLSearchParams(this.props.location.search);
const order = JSON.parse(params.get('order'));

 

 

2. push 방식으로 파라미터 전달

 

this.props.history.push('/joinComplete?name='+state.name+'&email='+state.email)

받는 쪽은 동일.