0

By default the first route i want it to send me to HOME but when we have something like "/user1234" to userProfileComponent. Now what it happens is that it loads both the Counter and the userProfileComponent.

Is there a way to control that even manually chekcing withe a RegEx or something maybe a rewritte. Like for example if I send /user/123 it will be showned as /user123. Thanks in advance. I think i use react-routerv4

<Layout> <Route exact path='/' component={Home} /> <Route path='/:userid' component={userProfileComponent} /> <Route path='/counter' component={Counter} /> </Layout>; import * as React from 'react'; import { RouteComponentProps } from 'react-router'; import { RotatingBanners } from '../controls/RotatingBanners'; import { BestOnline } from '../controls/BestOnline'; import { VideoBanner } from '../controls/VideoBanner'; import { PopularCategories } from '../controls/PopularCategories'; import { ExclusiveDeals } from '../controls/ExclusiveDeals'; import { SpotlightStoresFW } from '../controls/SpotlightStoresFW'; import { EmailSignUpFW } from '../controls/EmailSignupFW'; import { BlogFeatures } from '../controls/BlogFeatures'; export class Home extends React.Component<RouteComponentProps<{}>, {}> { public render() { return ( <div> <RotatingBanners /> <BestOnline /> <VideoBanner /> <PopularCategories /> <SpotlightStoresFW /> <ExclusiveDeals /> <EmailSignUpFW /> <BlogFeatures /> </div> ); } } 
11
  • Can you show a snippet of your home component ? Commented May 8, 2018 at 15:12
  • 2
    which version of react-router you're using? Probably you need to use Switch. Commented May 8, 2018 at 15:12
  • @MohamedELAYADI I updated it. :) Commented May 8, 2018 at 15:14
  • use exact on the user and counter routes Commented May 8, 2018 at 15:14
  • 1
    take a loot at this or this or even this Commented May 8, 2018 at 15:16

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.