我正在尝试使用ReactCSSTransitionGroup进行React路由器转换,并遵循了文档中的示例,但是得到了以下Uncaught TypeError: Cannot read property 'key' of undefined
我在做什么错?为什么未定义位置?
render() {
const {categories, language, location, reviews, subCategories} = this.props
return(
<Wrap>
<Router>
<ScrollToTop>
<Header categories={categories} language={language} />
<Wrap>
<TransitionGroup>
<CSSTransition
key={location.key}
timeout={{ enter: 300, exit: 300 }}
classNames={'fade'}
>
<Switch location={location}>
<Route exact path="/" render={props => <Home categories={categories} subCategories={subCategories} reviews={reviews} language={language} {...props} />} />
<Route exact path="/:catId" render={props => <ReviewsFilteredByCategory categories={categories} subCategories={subCategories} language={language} {...props} />} />
<Route exact path="/:catId/:slug" render={props => <ReviewsTop10 categories={categories} subCategories={subCategories} reviews={reviews} language={language} {...props} />} />
</Switch>
</CSSTransition>
</TransitionGroup>
</Wrap>
<Footer />
</ScrollToTop>
</Router>
</Wrap>
)
}
}