Comments (2)
I was thinking maybe we could find a solution if we flattened the loggedIn routes. I'm not 100% sure I'm parsing the issue as described, so this might not be a step in the right direction anyway. Ultimately, don't think this is a good avenue to explore as a change to boilermaker. But I did find it interesting.
<Switch>
{someCondition && [
<Route
path="/conditional-a"
component={() => <h1>Conditional A</h1>}
/>,
<Route
path="/conditional-b"
component={() => <h1>Conditional B</h1>}
/>,
]}
<Route
path="/non-fragment"
component={() => <h1>Not Conditional</h1>}
/>
<Route
path="/"
component={() => <h1>Home</h1>}
/>
</Switch>
Arguments against this:
- You get the elements in an array should have a
key
warning. - It mixes an array that looks A LOT like JSX and JSX side by side.
I also tried using <React.Fragment>
instead of the array, but React.Children.*
does not interpret fragment children the way we'd want it to.
from boilermaker.
Hm, that's an interesting possibility. I think the key
issue could obviously be mitigated by, well, adding key
s (the valye would be the path
. But that gets even more verbose / weird.
Maybe we can double down on this. Put all routes in arrays (and map
over them to add keys?), then make the Switch
contain a concatenation of them, e.g. [...publicRoutes, ...loggedInRoutes, ...fallbackRoutes]
or similar.
Alternatively, we back off from truly dealing with this in Boilermaker, but put in a comment that says if the inner switch
activates, nothing below it will work, so users need to add a fallback route to the inner switch
if applicable.
from boilermaker.
Related Issues (20)
- npm-merge-driver breaks heroku deployment HOT 2
- Do we need to destroy the session when a user logs out? HOT 1
- Babel stage-X plugins deprecated HOT 1
- make Prettier opt-out
- dev mode webpack HOT 1
- dev mode webpack HOT 7
- Demonstrate proper security (do not use req.body directly) HOT 1
- BUG: seed file, process.env.NODE_ENV = 'test', reference error 'after is not defined' HOT 3
- Prefer capability sniffing to environment check? HOT 3
- Run the build as part of travis testing?
- Make the travis.yml read the db name from the package.json?
- Run npm audit & also remove any obsolete deps
- Consider switching from Enzyme to React-Testing-Library HOT 2
- Use Volleyball instead of Morgan? HOT 1
- New syntax needed with "history" HOT 1
- Regression bug: Husky broken HOT 1
- js-yaml high security vulnerability
- Unable to deploy Google OAuth on herokuapp.com HOT 1
- Travis CI testing fails because of missing 'secrets.js' require in server/index.js
- As a customer/visitor, I want to be able to access a deployed version of the website so I can browse and purchase products.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boilermaker.