要求是将某些数据传递给将在路由更改时呈现的组件(以编程方式)。当前我使用来自'react-router-redux'的推送而不传递任何数据。
所以我正在导航到/Animal 并传递特定动物细节数据我希望 URl 显示http://localhost/Animal
我正在使用 React 路由器 4。
import {push} from 'react-router-redux';
export function changeRoute(newRoute, data) {
return (dispatch) => dispatch(push(newroute));
}
怎么能实现这一目标?
1 回答
您应该使用页面中的操作传递数据,并使用 Animal 页面中的相应 reducer 检索它。
在动物页面中,
然后,您可以使用道具访问数据。