Nicholas Haley Nicholas Haley - 1 year ago 80
React JSX Question

Getting started with React and Rails

I have started a new project in which I would like to use React and Rails. This project is on the small side and will require some basic interactive UI, hence React. As far as I know there are two ways I could get started with this:

  • Using the react-rails gem and use the built in view helper

  • Create a Rails API and React/Flux frontend app

I have a few questions however. In no particular order:

  • React-rails seems like the simpler solution, but what drawbacks would I be facing?

  • I come from a Rails and Ember background so the Rails API + React FE solution makes architectural sense to me. But with the react-rails gem I'm confused on how some things should be done. Primarily, how do I handle routing? I suppose I won't have access to any react route helpers and will need to pass paths into the react components as props?

Thanks in advance!

Answer Source

For a small project React-Rails,, is great I have used it in production the last year on 2 sites that get about hundred thousand visitors a month and I haven't had any issues.

That said if you want to use Redux, React-Router or Flux don't use React-Rails go the API route.

My rule is if you are just using React components then use React-Rails.

If you are doing a Redux, Flux app then just make a frontend app.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download