React-Rails Gem or React/Node?
Our team was tasked with building a React front end for a job search application created by mod 4 Turing students over the past couple of modules. Here is what the current front end looks like:
- A separate client-side app allows more freedom. Sure, there are some downsides- setup is definitely more complex. You have to setup your CSS, Bootstrap, and your module bundler (we are using Webpack). But theoretically, once the setup is complete, you can go about building your components.
- More flexible- not embedded in a Rails app. Could be more easily reused for other projects.
- Better learning opportunity. The setup may be painful, but we will learn a lot from the experience.
- You can still easily implement routes with react-routes.
If, however, you have a small application or are short on time, the react-rails gem is easy to implement. The setup is much faster than a React/Node app. Installation is easy-
Add the gem:
And in command line:
rails g react:install
In your Rails views, render component:
<%= react_component 'Main' %>
So far, we have had a pretty positive experience with our decision to make a React/Node front end. Sure, there are some growing pains, but our pages render quickly!