How to use React Router on top of Rails router (not using react-rails gem)?

后端 未结 2 1312
礼貌的吻别
礼貌的吻别 2020-12-16 11:24

Now i am making React app on top off Ruby on Rails app (with out react-rails gem) by using browserify-rails to compile js files.

So i tried to us react-router to con

2条回答
  •  天涯浪人
    2020-12-16 12:19

    If you want to redirect all your request to single page, that's easy:

    # config/routes.rb 
    
    root 'dash_board#index'
    get '*path', to: 'dash_board#index'
    

    If Rails will render your React components on DashBoard#index page, React's router will intercept it from there.

提交回复
热议问题