Skip to content

React generator has inconsistent paths generation #376

Open
@29Hido

Description

@29Hido
Contributor

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @29Hido

      Issue actions

        React generator has inconsistent paths generation · Issue #376 · api-platform/create-client