Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React generator has inconsistent paths generation #376

Open
29Hido opened this issue Feb 28, 2024 · 0 comments · May be fixed by #377
Open

React generator has inconsistent paths generation #376

29Hido opened this issue Feb 28, 2024 · 0 comments · May be fixed by #377

Comments

@29Hido
Copy link
Contributor

29Hido commented Feb 28, 2024

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

29Hido added a commit to 29Hido/create-client that referenced this issue Feb 28, 2024
@29Hido 29Hido linked a pull request Feb 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant