Reactjs React路由器在replace语句中传递值

Reactjs React路由器在replace语句中传递值,reactjs,react-router,react-router-redux,Reactjs,React Router,React Router Redux,我有一个带有onEnter参数的路由,当用户点击“/project”时,它会将用户重定向到默认(第一个)项目: 我需要项目组件中的项目,以便我可以列出它们。 现在我根本无法访问项目,它只是没有连接到组件 有点模糊: 更换(pathrloc) 与推送相同,只是将当前历史记录条目替换为新条目 而推压就像: router.push({ pathname: '/users/12', query: { modal: true }, state: { fromDashboard: true }

我有一个带有onEnter参数的路由,当用户点击“/project”时,它会将用户重定向到默认(第一个)项目:

我需要项目组件中的项目,以便我可以列出它们。 现在我根本无法访问项目,它只是没有连接到组件

有点模糊:
更换(pathrloc)
与推送相同,只是将当前历史记录条目替换为新条目

而推压就像:

router.push({
  pathname: '/users/12',
  query: { modal: true },
  state: { fromDashboard: true }
})
我假设负责/users/12/的组件可以通过this.state或this.props.route.state获取“fromDashboard”?为什么它不适用于替换

const redirectToDefaultProject = (nextState, replace, callback) => {
    $.get('/api/projects')
     .then((response) => {
        if (projects.length) {
              replace({
                pathname: '/projects/' + projects[0].id,
                state: { nextPathname: nextState.location.pathname,
                         projects: projects } // I can't get 'projects' in the Project component
              });
              callback();
            } 
     // else ...
     }
}
router.push({
  pathname: '/users/12',
  query: { modal: true },
  state: { fromDashboard: true }
})