Wrap all react-router routes with Switch (#1188)

This commit is contained in:
Fran Zekan 2023-05-11 16:09:09 +02:00 committed by GitHub
parent ef10d37357
commit 53ee9297f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 31 additions and 32 deletions

View File

@ -4,6 +4,7 @@
### Bug fixes
- Wasp CLI will now forward error exit codes. This will help when used in scripted contexts.
- Wasp now renders only the first route that matches the current path in the browser.
### Express middleware customization
We now offer the ability to customize Express middleware:

View File

@ -1,6 +1,6 @@
{{={= =}=}}
import React from 'react'
import { Route, BrowserRouter as Router } from 'react-router-dom'
import { Route, Switch, BrowserRouter as Router } from 'react-router-dom'
{=# rootComponent.isDefined =}
{=& rootComponent.importStatement =}
{=/ rootComponent.isDefined =}
@ -22,9 +22,7 @@ const router = (
{=# rootComponent.isDefined =}
<{= rootComponent.importIdentifier =}>
{=/ rootComponent.isDefined =}
{=^ rootComponent.isDefined =}
<>
{=/ rootComponent.isDefined =}
<Switch>
{=# routes =}
<Route exact path="{= urlPath =}" component={ {= targetComponent =} }/>
{=/ routes =}
@ -37,12 +35,10 @@ const router = (
{=/ authProviderEnabled =}
{=/ externalAuthProviders =}
{=/ isExternalAuthEnabled =}
</Switch>
{=# rootComponent.isDefined =}
</{= rootComponent.importIdentifier =}>
{=/ rootComponent.isDefined =}
{=^ rootComponent.isDefined =}
</>
{=/ rootComponent.isDefined =}
</Router>
)

View File

@ -473,7 +473,7 @@
"file",
"web-app/src/router.jsx"
],
"103724de16eb74300d9fab366bf73401ffd6bf9018394044c1d4ade22731868e"
"c1188ee948f821f5e3e7e741f54b503afffe4bdb24b8f528c32aee0990cf5457"
],
[
[

View File

@ -1,5 +1,5 @@
import React from 'react'
import { Route, BrowserRouter as Router } from 'react-router-dom'
import { Route, Switch, BrowserRouter as Router } from 'react-router-dom'
import MainPage from './ext-src/MainPage.jsx'
@ -7,9 +7,9 @@ import MainPage from './ext-src/MainPage.jsx'
const router = (
<Router>
<>
<Switch>
<Route exact path="/" component={ MainPage }/>
</>
</Switch>
</Router>
)

View File

@ -1,7 +1,7 @@
app waspBuild {
db: { system: PostgreSQL },
wasp: {
version: "^0.10.4"
version: "^0.10.5"
},
title: "waspBuild"
}

View File

@ -487,7 +487,7 @@
"file",
"web-app/src/router.jsx"
],
"103724de16eb74300d9fab366bf73401ffd6bf9018394044c1d4ade22731868e"
"c1188ee948f821f5e3e7e741f54b503afffe4bdb24b8f528c32aee0990cf5457"
],
[
[

View File

@ -1,5 +1,5 @@
import React from 'react'
import { Route, BrowserRouter as Router } from 'react-router-dom'
import { Route, Switch, BrowserRouter as Router } from 'react-router-dom'
import MainPage from './ext-src/MainPage.jsx'
@ -7,9 +7,9 @@ import MainPage from './ext-src/MainPage.jsx'
const router = (
<Router>
<>
<Switch>
<Route exact path="/" component={ MainPage }/>
</>
</Switch>
</Router>
)

View File

@ -1,6 +1,6 @@
app waspCompile {
wasp: {
version: "^0.10.4"
version: "^0.10.5"
},
title: "waspCompile"
}

View File

@ -858,7 +858,7 @@
"file",
"web-app/src/router.jsx"
],
"5c34b729d2244c792086224a6fae18c7bdfc029098a1fff9fe1685ba40af9d9b"
"ba66454c9f0ca79ed5bc6af694b5b9f748db75cf82309f2600c78069a3b9d0f7"
],
[
[

View File

@ -1,5 +1,5 @@
import React from 'react'
import { Route, BrowserRouter as Router } from 'react-router-dom'
import { Route, Switch, BrowserRouter as Router } from 'react-router-dom'
import App from './ext-src/App.jsx'
import createAuthRequiredPage from "./auth/pages/createAuthRequiredPage"
@ -11,10 +11,12 @@ import OAuthCodeExchange from "./auth/pages/OAuthCodeExchange"
const router = (
<Router>
<App>
<Switch>
<Route exact path="/" component={ MainPage }/>
<Route exact path="/auth/login/google">
<OAuthCodeExchange pathToApiServerRouteHandlingOauthRedirect="/auth/google/callback" />
</Route>
</Switch>
</App>
</Router>
)

View File

@ -1,7 +1,7 @@
app waspComplexTest {
db: { system: PostgreSQL },
wasp: {
version: "^0.10.4"
version: "^0.10.5"
},
auth: {
userEntity: User,

View File

@ -501,7 +501,7 @@
"file",
"web-app/src/router.jsx"
],
"103724de16eb74300d9fab366bf73401ffd6bf9018394044c1d4ade22731868e"
"c1188ee948f821f5e3e7e741f54b503afffe4bdb24b8f528c32aee0990cf5457"
],
[
[

View File

@ -1,5 +1,5 @@
import React from 'react'
import { Route, BrowserRouter as Router } from 'react-router-dom'
import { Route, Switch, BrowserRouter as Router } from 'react-router-dom'
import MainPage from './ext-src/MainPage.jsx'
@ -7,9 +7,9 @@ import MainPage from './ext-src/MainPage.jsx'
const router = (
<Router>
<>
<Switch>
<Route exact path="/" component={ MainPage }/>
</>
</Switch>
</Router>
)

View File

@ -1,7 +1,7 @@
app waspJob {
db: { system: PostgreSQL },
wasp: {
version: "^0.10.4"
version: "^0.10.5"
},
title: "waspJob"
}

View File

@ -487,7 +487,7 @@
"file",
"web-app/src/router.jsx"
],
"103724de16eb74300d9fab366bf73401ffd6bf9018394044c1d4ade22731868e"
"c1188ee948f821f5e3e7e741f54b503afffe4bdb24b8f528c32aee0990cf5457"
],
[
[

View File

@ -1,5 +1,5 @@
import React from 'react'
import { Route, BrowserRouter as Router } from 'react-router-dom'
import { Route, Switch, BrowserRouter as Router } from 'react-router-dom'
import MainPage from './ext-src/MainPage.jsx'
@ -7,9 +7,9 @@ import MainPage from './ext-src/MainPage.jsx'
const router = (
<Router>
<>
<Switch>
<Route exact path="/" component={ MainPage }/>
</>
</Switch>
</Router>
)

View File

@ -1,6 +1,6 @@
app waspMigrate {
wasp: {
version: "^0.10.4"
version: "^0.10.5"
},
title: "waspMigrate"
}

View File

@ -1,6 +1,6 @@
app waspNew {
wasp: {
version: "^0.10.4"
version: "^0.10.5"
},
title: "waspNew"
}

View File

@ -6,7 +6,7 @@ cabal-version: 2.4
-- Consider using hpack, or maybe even hpack-dhall.
name: waspc
version: 0.10.4
version: 0.10.5
description: Please see the README on GitHub at <https://github.com/wasp-lang/wasp/waspc#readme>
homepage: https://github.com/wasp-lang/wasp/waspc#readme
bug-reports: https://github.com/wasp-lang/wasp/issues