如何在 React 路由器中的组件内部进行重定向?我正在使用 react-rouer
import React from 'react'
import _ from 'lodash';
import FavoriteItem from '../components/FavoriteItem'
const FavoritesList = ({list}) => {
let transitionToItem = ({id}) => {
// make transition to `/details/${id}`
};
return (
<ul className="list-group favorites-list">
<FavoriteItem onFavoriteClick={ () => { transitionToItem(item); } } key={item.id} item={item}/>
</ul>
);
};
export default FavoritesList
路线:
<Route path="details/:item" name="details" component={DetailsPage}/>