Custom Routes in react admin
Asked Answered
M

1

6

I have created a custom route

<Route
    path="/course-plan/:plan_id/plan-lesson/:id"
    render={props => {
      return <LessonEditPage 
        {...props} 
        resource={'plan-lesson'} 
        record={{planId: props.match.params.plan_id}} 
     />
    }}
  />,

LessonEditPage has and Edit component with SimpleForm

When I enter this page, I make a request crudGetOne and locally everything is fine, I have and id in my parameters that I use to make request, but when I deploy this code on server, when I enter this page params.id is undefined

I have no idea why and what can be the problem

Mancunian answered 25/7, 2018 at 18:2 Comment(0)
F
4

You should create a routes.js file:

import React from 'react';
import { Route } from 'react-router-dom';
import LessonEditPage from './LessonEditPage';

export default [
    <Route exact path="/course-plan/:plan_id/plan-lesson/:id" component={LessonEditPage} />];

Then import the file in your App.js

import customRoutes from './routes';


<Admin
     dataProvider={dataProvider}
     customRoutes={customRoutes}
/>
Finagle answered 29/7, 2019 at 15:1 Comment(1)
An example with a <Button> component that links to that route would be great!Workmanship

© 2022 - 2024 — McMap. All rights reserved.