2017-01-12 3 views

答えて

0

リアクタールータhttps://github.com/ReactTraining/react-routerを使用すると、アプリの簡単なルーティングを作成できます。

あなたの場合、指定されたユーザーの動的ルートを作成する必要があります。

<Router history={browserHistory}> 
    <Route path="/" component={App}> 
    <Route path="users" component={Users}> 
     <Route path="https://stackoverflow.com/users/:userName" component={User}/> // dynamic route 
    </Route> 
    <Route path="*" component={NoMatch}/> 
    </Route> 
</Router> 

次のステップは、User成分に

class User extends React.Component { 
    componentDidMount: function() { 
    const userName = this.props.params.userName 
    ... 

をURLからuserNameを取得し、簡単のために任意のデータをロードするために、指定されたuserName

関連する問題