我用
"react": "^16.5.0",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
有路由器
import * as React from 'react';
import { Route, Switch } from 'react-router-dom';
import GoToNode from './components/map/GoToNode';
const Router = (props) => {
return (
<Switch>
<Route path="/*/node/:nodeId" component={GoToNode} />
</Switch>
);
};
export default Router;
当我刷新页面'localhost:3000 / project / node / 5'时,路由器呈现GoToNode组件。当我从另一个组件使用功能'selectNode'时,未呈现GoToNode。
selectNode(node: Node) {
this.props.history.push(`/project/node/${node.objectId}`);
}
...
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(NodeWorkingList));
你知道为什么吗?谢谢! :)