I am an experienced ruby on rails developer and trying to use reactjs with it. So I installed react-rails gem and followed the instructions.
There are two possible approaches to get started:
- Using asset pipeline
- Using webpacker
Webpacker gem looks pretty new and I had hard time getting the webpacker-dev-server work with my current rails app. And also running two process using foreman (one for rails and one for webpacker) looks too many dependency.
So I went ahead with asset pipeline approach by placing all my React components in app/assets/javascripts/components/MyComponent.jsx
. Everything works fine and I am able to render the component using <%=reach_component("MyComponent")%>
Now I want to design a Single Page app around it. Hence I started exploring about react-router. But there is no proper explanation on how to use react-router
with react-rails
gem.
I tried adding the react-router package
in packages.json
and ran yarn
but ended up with the following error on browser after all the include.
Uncaught ReferenceError: exports is not defined
Any help on getting started with react-router and rails without webpack and without using babel in browser and making client heavy ?