Ad

How Can I Manage Reactjs Component Files In Rails, Since The App Now Has So Many Reactjs Components?

- 1 answer

I'm using react-rails gem to work with Reactjs in my Rails application. Everything works well until the frontend becomes to have so many components which were defined in the separated file.

The problem is every time the application was loaded, all of those files were downloaded to the browser. I know it is obvious, but kind of inefficient, because only a few react component will be used in a session.

Here is my current workspace:

--assets
----javascripts
------components
--------component_1.js.coffee
--------....
--------component_n.js.coffee

I just wonder is there any working solution to optimize this?

Ad

Answer

Reactjs does not support this, but there are other libraries you can use (requirejs for example).

A very good open source solution is LABjs.

Another one is https://webpack.github.io/.

There are others. See this discussion on reactjs site.

Ad
source: stackoverflow.com
Ad