score:0
i ended up creating a subroutes object and mapping around that to create new routes just below the first map. it should render its own route tag which is what i was going for. if anyone else has a different approach would be good to see it :)
const subroutes = [
{ path: `/blog/:id(\\d+)`, name: 'post', component: postpage },
{ path: `/projects/:id(\\d+)`, name: 'project', component: projectspage },
]
{routes.map(({ path, component }) => (
<route key={path} exact path={path}>
{({ match }) => <component data={dataobject} imagepath={imagepath} in={match != null} />}
</route>
))}
{subroutes.map(({ path, component }) => (
<route key={path} exact path={path}>
{({ match }) => <component data={dataobject} imagepath={imagepath} in={match != null} />}
</route>
))}
Source: stackoverflow.com
Related Query
- Nested React routes with dynamic route tags
- React Routes problem with Tags other than Route
- Building a dynamic nested routes architechure with React and React Router
- React router v5: need a nested route in dynamic routes
- Nested routes with react router v4 / v5
- React Router v4 Nested Routes with Switch
- Webpack 2 + React - nested routes when code splitting with System.import
- React Router doesn't load images properly with nested routes
- React router nested routes - How to redirect when no route is matching
- How to use meta tags with dynamic value in react js?
- React Router v4 nested routes not work with webpack-dev-server
- How to use nested routes to add content to a page without removing the content of the previous route with react-router-v4?
- How to use multiple nested dynamic routes with getStaticPaths?
- Nested Routes not rendering with React Router v4
- React Router: Route with nested params not hit
- Nested routes with react router v4 not working
- Nested Routes in React not rendering correctly with react-router v4
- How to access previous index route in nested routes using Link component from react router?
- How to use Laravel routes alongside with React SPA single route in Laravel 8
- React Route does not work with nested URLs
- React Router v4 - Dynamic Config with the changed default route
- Nested routes and not found route in react router dom v5
- How to route correctly with a mixture of parent and child routes with React Router
- react router 4 - how to make a root path with nested routes but fallback to not-found
- React Nested Route with params
- React Router Switch statement with routes grouped as component inside does not go to Not Found route
- how to prevent react-router-dom nested routes to get confused with route params
- How to link to Routes inside the component rendered by another Route with React Router
- Nested Routes with React Router v4 - Solutions
- Nested routes inside a route not working - React
More Query from same tag
- Using react suspense to load asynchronously from Firebase
- Hide broken image link in Semantic UI React
- Why is BrowserRouter and Route from 'react-router-dom' not working properly?
- How to fix JSX expression must have one parent element?
- convert length to point in svg (polygon) dynamically
- Retrieving Array from Contentful GraphQL query for page created by slug build error
- Getting the individual field from response ReactJS
- MUIDataTable : onRowclick show data from json in selectable tooltip rather then as a column
- Data fetching from graphql server with ApolloClient doesn t work. How can I fix it?
- react combine differents wrappers
- How can I store the currentState in react and set it again if something went wrong?
- Do Lifecycle method's trigger again on setState?
- React + Firebase Cloud Functions in Typescript fails to deploy
- React/Javascript - Need a better solution for progress bar logic
- How do I prevent drop in originating container in react js and react-beautiful-dnd?
- How to override StepLabel default label?
- Securing a React frontend and with Python API using AWS Cognito
- How to reset the react-select component to defaultValue state after form submit
- Getting an Error: Before running a Saga, you must mount the Saga middleware on the Store using the applyMiddleware
- React adding/removing items to an array
- Open modal component when submit axios post
- How to change react-bootstrap carousel animation ton fadein?
- Multiple delete function on server and frontend
- Dynamic routing and lifecycle in react
- How can I store an API auth token using React?
- "Error watching file for changes: EMFILE" when init a react-native project
- No component displayed when adding a custom label to a ReferenceLine in Recharts
- How to remove PWA service worker from domain
- Persona - onRenderPrimaryText - pass addt'l parameters?
- Multiple drop targets react-dropzone