のは、私は、次のルートが設定されているとしましょう(単なる例、実際のルートは、この厄介ではありません):反応ルータの異なるパラメータで現在のページにリンクするにはどうすればいいですか?
<Router>
<Switch>
<Route path="/app/fun/:userid/profile" component={Profile} exact/>
<Route path="/photos/:userid" component={Photos} exact/>
<Route path="/:userid/contact" component={Contact} exact/>
</Switch>
</Router>
から任意上記ページの、どのように私は同じにリンクすることができますページが異なるが、userid
?
例:
/**
* Shared component that's rendered by Profile, Photos and Contact
*/
class SharedComponent extends React.Component {
render() {
const bobId = 423423432;
return (
<div>
<Link to={/* what to put here? */}>
Redirect to the same page but with Bob's userid
</Link>
</div>
);
}
}
export default withRouter(SharedComponent);
注:パスと
ですどのように同じページから同じページにリンクするが、別のデータを渡すのあなたの質問? – linasmnew
これはすべてのページで使用されている共有コンポーネントで、現在のページ(別のデータを使用)にリダイレクトするそのコンポーネントのリンクをレンダリングしたい – Vic
私の質問を更新しました – Vic