Skip to content

React generator has inconsistent paths generation #376

@29Hido

Description

@29Hido

Description
React generator has problem with paths for resources.
I generated a client using https://demo.api-platform.com/, while the generated routes have paths like /admin/books/create the Show components has paths like <Navigate to="/books/" replace />

How to reproduce

  1. Generate a client with rm -rf ./tmp && yarn build && ENTRYPOINT=https://demo.api-platform.com/ ./testgen.sh react
  2. Go to tmp/react/routes/book.tsx you will see
const routes = [
  <Route path="/admin/books/create" element={<Create />} key="create" />,
  <Route path="/admin/books/edit/:id" element={<Update />} key="update" />,
  <Route path="/admin/books/show/:id" element={<Show />} key="show" />,
  <Route path="/admin/books" element={<List />} key="list" />,
  <Route path="/admin/books/:page" element={<List />} key="page" />,
];
  1. Go to tmp/react/components/book/Show.tsx and you can see
<Link to="/books/" className="btn btn-primary">
        Back to list
</Link>

image

Possible Solution
Use the same variable in all template when generating routes and links

Additional Context
PR here : #377

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions