嵌套路由不适用于react-router

阿卜杜勒瓦哈卜

我一直在尝试渲染CollectionPage并将URL与我的页面匹配,但是由于某种原因,调用CollectionPage的嵌套Route无法正常工作!

这是我的shop.component的一个片段,正在app.js中调用

import React from 'react';
import { Route } from 'react-router-dom';

import CollectionOverview from '.././../components/collections-overview/collections-overview.component';
import CollectionPage from '../collection/collection.component';

const ShopPage = ({ match }) => (

    <div className='shop-page'>
        <Route exact path={`${match.path}`} component={CollectionOverview} />
        <Route path={`${match.path}/:collectionId`} component={CollectionPage} />
    </div>

);


export default ShopPage;

阿卜杜勒瓦哈卜

我发现发生了什么,在我的app.js中,我不小心设置了path ='/ shop /',所以我只需要删除第二个'/'

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章