0

I am using React Js with rails 5.0

Important Gems are

gem 'rails', '~> 5.0.2'
gem 'react-rails'
gem 'react-router-rails' 
gem 'slim-rails'

my layout and page template is in slim and I am using coffee everywhere.

I am facing lots of problem when I am using react router.

List of questions are:

  1. I want to get a clean approach like angular where I can use module + controller + views in react. Can be it possible?

  2. As now I am using react-router but the thing is that when it send request to the server so request comes to my action controller, action view and layout but does not load react components.

  3. I am not able to use new packages like react-validation( https://www.npmjs.com/package/react-validation). How can I use react packages.

  4. In react routing I want to send request on server and then it loads components which is exist on that action view.

  5. Suggest me for the best approach of using react js + rails

henrycarteruk
  • 12,708
  • 2
  • 36
  • 40

1 Answers1

0

Let's start with the basics, and I apologize if it sounds too basic.

  • 'React' can be viewed as the Facebook JavaScript libraries, the set of JavaScript libraries put out by a community of React users, or the base design philosophy of nested component rendering and tag based caching.
  • JavaScript is inherent to React libraries, but not to its philosophy.
  • React on Ruby can be viewed as copying the philosophy or of cross-compiling to or generating JavaScript, or possibly emulating JavaScript in Ruby.
  • React is inherently a 'View' component, with additional libraries use a component and JSX approach to other capabilities. React-router is such a library.
  • React is not Angular. Angular is more of an MVC framework.

You probably want to go down these paths: * Acquire the ability to code in JavaScript. Running on the browser implies code in JavaScript. * Use Rails only as a server side REST or GraphQL endpoint. Alternately, use Rails to emit JavaScript and then use as REST or GraphQL endpoint. * Non JavaScript code will not be able to use the latest JavaScript libraries.

It's good to think of the possibilities of what can be done, and this question suggests you are exploring.

Charles Merriam
  • 19,908
  • 6
  • 73
  • 83
  • Much Thanks for above. Now the things are making too complicated at the initial stage. So I would like to rollback and get start from initially. I want a to develop a full app with rails and react. So please provide me a best approach for the same in terms of conclusion and please try to make sure it may fulfil below criteria. 1- Structured Approach in react js 2- Full View in React Js 3- Backend in RAILS 4- Routing clean 5- Convention over configuration applied. 6- Module wise integration 7- Test cases required in react. – Rubyone Railsone Mar 25 '17 at 17:27