Reputation: 31
I am new with React and today I was working on react-routers. I am not clear which routes to use. My choices are Rails routing or React router. What are the difference between these?
Upvotes: 3
Views: 1072
Reputation: 628
React should be used for rendering and Rails should be used for the API. Each react app should have its own server-rendered path, with calls to a rails API on the backend. The API should definitely be routed with rails, but only pass back the data you need to the react app. Rails 5 has ApiController you can use for your controller superclass. TL;DR - React is frontend, rails API on the backend.
Also, you should really determine if you need something so heavyweight on the backend. Some lighter ruby alternatives are Sinatra and Padrino.
Upvotes: 1
Reputation: 1547
You can use them for both server side and client side. If you are fully MEAN stack then you can use that. If you are in Rails stack then it's not possible.
Upvotes: 0