【发布时间】:2018-01-09 04:21:50
【问题描述】:
我正在尝试通过父组件的 Click 事件来渲染子组件。 这是父组件。我在父组件中选择开始日期和结束日期。
handleStartDateChange = (e, date) => {
this.setState({ startDate: date });
}
...
handleFilterClick = () => {
let urlGetCashListByDate = urlGetCashList + '?starttime=' + this.state.startDate +'&endtime=' + this.state.endDate;
let urlGetOrderListByDate = urlGetOrderList + '?starttime=' + this.state.startDate + '&endtime=' + this.state.endDate;
}
render() {
return (
<DatePicker
id="start-date"
onChange={this.handleStartDateChange}/>)
<DatePicker
id="end-date"
hintText="End Date"
onChange={this.handleEndDateChange}/>
<RaisedButton
onClick={this.handleFilterClick}/>
<OrderList/>
<CashList/>
)}
这是子组件:
class OrderList extends Component{
componentDidMount(){
this.props.getOrderList(urlGetOrderList);
}
和 CashList 子组件:
class CashList extends Component{
componentDidMount(){
this.props.getCashList(urlGetCashList);
}
如何像这样使用父组件的新 URL 来渲染子组件? (在 CashList 组件中)
this.props.getCashList(urlGetCashListByDate)
我知道passing a state,但我的问题是 url。 谢谢。
【问题讨论】:
标签: reactjs