Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotFound route doesn't render with conditional statement inside of switch (conditionally mounted routes) #6128

Closed
r3wt opened this issue May 3, 2018 · 2 comments

Comments

@r3wt
Copy link

r3wt commented May 3, 2018

Version

4.2.0

Test Case

Steps to reproduce

A switch with some conditional mounted routes like so:

{this.props.store.loggedIn ?
<React.Fragment>
    <Route exact path='/account/details' component={AccountDetails} />
    <Route exact path='/account/my-reviews' component={AccountReviews} />
    <Route exact path='/providers/review/:id?/:token?' component={LeaveReview} />
    {this.props.store.user.type=='provider' &&
        <React.Fragment>
            <Route exact path='/providers/dashboard' component={ProviderDashboard} />
            <Route exact path='/providers/account' component={AccountDetails} />
            
            <Route exact 
                path='/providers/edit/:section(contact-information|images|overview|amenities|pricing)?' 
                component={ProviderEdit} />
            <Route exact path='/providers/preview/:section(contact-information|images|overview|amenities|pricing)?' component={ProviderListingPreview} />
        </React.Fragment>
    }
</React.Fragment>
:
<React.Fragment>
    <Route exact path='/account/details' render={()=><Redirect to='/?dialog=login' />} />
</React.Fragment>
}

if i replace the above with this it works:

<Route exact path='/account/details' component={AccountDetails} />
<Route exact path='/account/my-reviews' component={AccountReviews} />
<Route exact path='/providers/dashboard' component={ProviderDashboard} />
<Route exact path='/providers/account' component={AccountDetails} />
<Route exact path='/providers/review/:id?/:token?' component={LeaveReview} />
<Route exact 
    path='/providers/edit/:section(contact-information|images|overview|amenities|pricing)?' 
    component={ProviderEdit} />

Expected Behavior

NotFound route renders if no others match

Actual Behavior

NotFound route doesn't render if no others match

@r3wt r3wt changed the title after upgrade to 4.2.0, NotFound route no longer renders after upgrade to 4.2.0, NotFound route no longer renders, but only if there are conditional routes in Switch May 3, 2018
@r3wt r3wt changed the title after upgrade to 4.2.0, NotFound route no longer renders, but only if there are conditional routes in Switch NotFound route doesn't render with conditional statement inside of switch (conditionally mounted routes) May 3, 2018
@timdorr
Copy link
Member

timdorr commented May 3, 2018

Switch doesn't work with Fragments and won't (at least according to Michael): #5892

@timdorr timdorr closed this as completed May 3, 2018
@r3wt
Copy link
Author

r3wt commented May 4, 2018

bah, that's great.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants