-
Notifications
You must be signed in to change notification settings - Fork 254
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
Mention React usage in Readme #327
Comments
I don't understand exactly what the helper accomplishes here. Can you just do import route from 'ziggy';
import { Ziggy } from './ziggy'; right where you actually need to use the |
Yes i could do this also but then i need to mention every time the custom Ziggy as argument to the route function call. |
@lodzen great point 😂 I'll think about how we can make this easier for React users, and in the meantime I'll update the Readme to link here. Thanks! |
I took a quick stab at a Hook that does something quite similar to your helper: useRoute (Ziggy Hook) I could see this being something that might be worth including in Ziggy out of the box. |
This looks great and i would appreciate it if this would be part of Ziggy. |
How do we use this hook without having to import the Ziggy file everytime? |
Description
I struggled a lot with the usage in a React Application.
The problem was that i don't want to put the
@routes
blade directive in the header of my application because everyone can see all routes directly if the source code is inspected.Due to this i wanted to go with option two to generate the Ziggy file and use it as custom Ziggy in the route() function.
In the Readme i could only find the Vue solution to use a mixin for this purpose but nothing related to React.
Suggestion
I wrote a very small helper that did the trick for me.
Maybe this one can also be mentioned in the Readme to save some time i someone has the same issue.
I called the file ziggyroutes and imported it in my application in the view where i need it.
Additionally the helper methods are mentioned in the function like current(), check() and url().
If there are any improvements for the small helper please feel free to change it.
The text was updated successfully, but these errors were encountered: