【发布时间】:2022-01-12 12:07:56
【问题描述】:
我有一个导航组件,我在其中将参数传递到另一个页面,正在传递参数,但是,下拉列表中的数据并未针对传递的 ID 进行更新:
导航:
<Link to='/service/ServiceAppointment/${car.Make}'> { serviceAppointment } </Link>
预约页面:
const ScheduleAppointment = () => {
const { id } = useParams();
console.log (id); //I can see the ID passed to the page in the console
useEffect(() => {
console.log(id); //the ID is not there
scheduleAppointment(id);
});
const Appointment= () => {
//call to API for open dates
//the ID never gets here
}
}
路由器:
<Route exact path='/service/appointment/:id' component={ ScheduleAppointment } />
当一个新的 ID 被传递给预约页面时,我怎样才能改变它?
【问题讨论】:
标签: reactjs react-native react-hooks react-router