2016-08-04 8 views

答えて

1

ReduxをReact-Routerアプリに接続すると、同じ問題が発生しました。

あなたは私にあなたの全体のルーティングを入れていないので、デフォルトのようなものをやっていると仮定しなければならない、それは次のようになりリアクト・ルータのチュートリアルでルーティング提案:「あなたの場合は

<Router history={browserHistory}> 
    <Route path="/" component={App} > 
     <IndexRoute component={IndexPage} /> 
     <Route path="profile" component={ProfilePage} > 
      <Route path="edit(/:profileId)" component={EditProfile} /> 
      <Route path="add(/:profileId)" component={AddProfile} /> 
      <Route path="view/:profileId" component={ProfilePage}/> 
     </Route> 
    </Route> 
<Router /> 

を同様の構造を使用して、このようなコンテナコンポーネント「アプリケーション」にReact.cloneElementを()を使用しているRE:

{React.cloneElement(this.props.children, this.props)} 

あなたはそれがすべての子として「ProfilePage」をクローニングだとしてネストを削減する必要があります子供たちも。

<Router history={browserHistory}> 
    <Route path="/" component={App} > 
     <IndexRoute component={IndexPage} /> 
    </Route> 
    <Route path="/profile" component={ProfilePage} > 
     <Route path="edit(/:profileId)" component={EditProfile} /> 
     <Route path="add(/:profileId)" component={AddProfile} /> 
     <Route path="view/:profileId" component={ProfilePage}/> 
    </Route> 
<Router /> 

'App'以外の経路の子がない場合は、おそらく 'IndexPage'コンポーネントを削除することができます。

...これを入力した後、私はあなたのモーダルとのあなたの小さな画像のリンクを見ました。私はこれがまだあなたの問題だと信じています。 React.cloneElementを使用して親にルートを深く入れ子にすることは、これを引き起こす可能性があります。 cloneElementではなくcreateElementを使用すると、参照の問題を避けることができます。ここでそれを見てみましょう:Create Elementもう一つの選択肢は、プロップをマップするためのドキュメントでも同様にcreateComponentです。私はまだそれを試していない。

0

おそらくIndexRouteをしたいを参照してください場合、私は

 <Route path="profile" component={ProfilePage} > 
     <Route path="edit(/:profileId)" component={EditProfile} /> 
     <Route path="add(/:profileId)" component={AddProfile} /> 
     <Route path="view/:profileId" component={ProfilePage}/> 
     </Route> 

私の問題をが何をしています。

<Route path="profile"> 
    <IndexRoute component={ProfilePath} /> 
    <Route path="edit(/:profileId)" component={EditProfile} /> 
    <Route path="add(/:profileId)" component={AddProfile} /> 
    <Route path="view/:profileId" component={ProfilePage}/> 
</Route> 
+0

モーダルウィンドウプロファイルを開いているときに、私はそうでなければならない( 'view'または' profile'(現在)) [リンク](http://prntscr.com/c1ce7p) ありがとう –

+0

http: /prntscr.com/c1ce7p –

+0

私はあなたのコメントを理解していません。あなたのリンクから、私の答えがうまくいくと思います。まだ助けが必要な場合は、質問を更新してください。 – Jack

関連する問題