I have a laravel app.
For pages with such routing: /admin/entity/
i want to use react ponents with react router to handle /admin/entity/:id
route.
If i use browserify to bundle all ponents in one file, i can't access any ponent to render it from outside since browserify wraps it to closure. Thus, i have few questions:
*.blade.php
file?I have a laravel app.
For pages with such routing: /admin/entity/
i want to use react ponents with react router to handle /admin/entity/:id
route.
If i use browserify to bundle all ponents in one file, i can't access any ponent to render it from outside since browserify wraps it to closure. Thus, i have few questions:
*.blade.php
file?- 2 If your bundle has a client-side router in it then it doesn't matter if it's a single bundle (for that reason) – nanobar Commented Jun 30, 2015 at 10:23
- but if i user client-side router it captures the whole url on every page and tells that route is not found in other pages – Semyon Zhikharev Commented Jun 30, 2015 at 10:47
1 Answer
Reset to default 4Here are my opinions:
- You should bundle React and all your code in all pages that will have any part rendered by React ponents (From what I gather,
/admin/entity
). - Your React ponent should always be rendered to a specific element (e.g., an empty
<div>
) and should have something like a React Router configured so that it ignores/admin/entity
but renders/admin/entity/:id
. Your challenge is that any links that point to a different:id
URL should optimally be inside the React ponents, usingLink
ponents. This will hook up your router automatically.
Your routes will probably look like this:
<Route path="admin/entity/:id" handler={Entity} />
I believe that, when you run
the Router, if the browser's URL isn't in the expected format, React won't actually render anything.