任何人都可以告訴我如何在使用react-router進行路由更改服務器端反應減少組件中的路由URL時如何調用動作。更改URL和調用redux動作以獲取反應減少應用程序中的數據
我正在使用瀏覽器歷史 react-router將我的輸入推送到url。
import React from 'react';
import { connect } from 'react-redux';
import { browserHistory } from 'react-router';
class findBirthdays extends Component {
constructor(props){
super(props);
}
openCalender(){
// here I open the date picker and let user select the date
// then I add that date in the URL as "localhost:3000/find/?date=22-02-2017"
// here I get confused as I do not know now how to dispatch the action or
// how to access url params in a specific actions after dispatching that action
}
render(){
return (
// repeating all the birthday that are available on selected date
)
}
}
const mapStateToProps = (state) => {
return {
birthdayList: state.birthdays,
};
};
export default connect(mapStateToProps)(findBirthdays);
我有許多投入和每個輸入變化事件,將附加的URL,並且應該導致調度動作並得到正確的結果。
我是新來的反應和redux,所以如果任何人都可以建議,如果這可以做到或如何處理這個問題,這將是有益的。 謝謝你們。
所以你想'調度'一個'行動'或只是改變'路線'與'日期查詢'? –
@JyothiBabuAraja如果我選擇日期,它應該添加到網址,並且該網址更改應該調度將採取url參數進行進一步處理的操作。我已經做了將它添加到URL部分。我需要第二部分的幫助。 – NitinD
你可以閱讀像'this.props.location.query.date'這樣的url查詢參數。 –