嵌套路由未显示正确的组件

问题描述

我试图将ShopPage组件中的CollectionPage组件显示为一个嵌套路由,该路由接收collectionId作为参数,但我得到一个空页面。 这些是我的组件。

商店页面:

import React from 'react';
import CollectionsOverview from '../../components/collections-overview/collections-overview.component';
import { Route } from 'react-router-dom'
import CollectionPage from '../collection/collection.component';

const ShopPage = ({ match }) => (
    <div className='shop-page'>
        < Route exact path={`${match.path}`} component={CollectionsOverview} />
        <Route exact path={`${match.path}/collectionId`} component={CollectionPage} />
    </div>
)

export default ShopPage;

CollectionPage组件:

import React from 'react';
import CollectionItem from '../../components/collection-item/collection-item.component';
import './collection.styles.scss';


const CollectionPage=({match})=>{
    console.log(match);
    return(
    <div className="collection-page">
        <h2>Collection Page</h2>
    </div>
)}

export default CollectionPage;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)