Is it not possible to use Redux with this gem?
I am aware of react_on_rails but I don't want to migrate to another gem which can lead to unnecessary complexities.
There's no reason you _can't_ use Redux with this gem! You can use this gem to transform JSX and insert React components into Rails views. Your React components can interact with Redux any way they want!
@rmosolgo Thank you so much for your answer. This was rather a non-fruitful question. If you don't mind answering a few more, I am curious about the following:
react-rails necessarily couples frontend and backend?react-rails provide compared to a node-packaged React?Do you think react-rails necessarily couples frontend and backend?
Yes, to the same degree that off-the-shelf Rails couples frontend to backend. I think this is a feature: There's only one project -- no overhead for switching projects (same repository, same development team, same build tools, same deployment strategy). Because they are "coupled", you can fetch exactly the data you need when you need it.
It makes it very easy to add new features and fix things, which is what people really want :shipit:
What advantage does react-rails provide compared to a node-packaged React?
I think the biggest advantage is that you don't have to use Node.js :laughing:. npm is not great. For "normal" Rails developers (or any developer who started of with <script> tags), the cognitive overhead of require (or import) makes development and in-browser debugging harder. The asset bundlers (webpack, browserify) are good, but they aren't better than Sprockets (maybe rollup is, but nobody uses that, right?).
I'm happy to stay heavy on Rails and light on Node.js. There are a few nice things that I'd like (named imports, sourcemaps), but I don't think they're worth all the overhead they bring with them!
:+1: :+1: Thanks!!
@rmosolgo I actually tried to setup redux but haven't succeeded yet.
What do you think is the easiest way to setup redux to get it work with react-rails gem?
Hmm, what I do with dependencies is:
assets/javascripts/vendor/{library-name}-v{version}.js //= require vendor/{library-name}-v{version} Then the library's object is available as a global (eg, window.Redux).
Does that flow work with Redux?
@woniesong92 You might consider https://github.com/shakacode/react_on_rails/. We have built-in support for Redux, including a Rails generator. See http://www.reactrails.com/ for a live example.
@rmosolgo I'm also running into issues using redux: https://github.com/reactjs/react-rails/issues/878
Most helpful comment
@woniesong92 You might consider https://github.com/shakacode/react_on_rails/. We have built-in support for Redux, including a Rails generator. See http://www.reactrails.com/ for a live example.