How to use response.js with a multi-page website (Non SPA)?

I have a laravel application. For pages with this routing: /admin/entity/ I want to use responsive components with a responsive router to handle the route /admin/entity/:id .

If I use browserify to merge all components into a single file, I cannot access any component to display it from the outside, since the browser wraps it until it closes. So I have few questions:

Should I create a separate bundle.js file for each page and explicitly display the components in this file? Or do I need to precompile each component from jsx to js and make it inline from the *.blade.php file? does it make sense to enable the library response to bundle.js or can I load it explicitly from the view?
+6
source share
1 answer

Here are my opinions:

  • You should link React and all your code on all pages that will have any part displayed by React components (from what I am compiling, /admin/entity ).
  • A React component should always be passed to a specific element (for example, an empty <div> ) and should have something like a React Router configured to ignore /admin/entity but display /admin/entity/:id . Your problem is that any links that point to another URL :id should optimally be inside React components using Link components. This will automatically connect your router.

Your routes are likely to look like this:

 <Route path="admin/entity/:id" handler={Entity} /> 

I believe that when you run Router, if the browser URL is not in the expected format, React will actually do nothing.

+1
source

Source: https://habr.com/ru/post/990002/


All Articles