Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing react-redux in a Rails project

I am building a React app in Rails and would like to try react-redux. I noticed that it doesn't offer a CDN nor a bower package.

The installation instructions recommend using NPM, but this is not a node project. I handle all my current assets through the Rails asset pipeline, a CDN or a bower package (via rails-assets)

  • Is there a way to install it without using NPM?
  • Is there a way to get NPM packages to play nice with existing asset pipeline packages?
like image 997
Rick Avatar asked Sep 18 '15 18:09

Rick


People also ask

How do you add react to an existing Rails project?

First, you need to add the gem to your gemfile by running the command gem 'react-rails' and install the gem by running bundle install and react-rails installation script: rails g react:install . These actions will create a directory for the components and manifest file, and add them to the application.

Can you use react with rails?

There are a few different ways to use React inside Ruby on Rails apps. With the recent improvements in native support in Rails for JavaScript tooling, it's now easier than ever to start using JavaScript libraries, including React, with Rails. You can also use React in a separate frontend app with a Rails API.

Does Ruby on Rails work with react?

There are two ways to use React with Ruby on Rails. The first is to build two separate, standalone apps, with the React app on a different repository and communicating with the backend via an API. This can simply be achieved by creating both apps separately using Create React App and the Rails CLI.


2 Answers

You can also check out https://github.com/shakacode/react_on_rails. It's integrated with webpack which gives it a nice and familiar javascript flow.

They've also got a live example at http://www.reactrails.com/ and the code for that at https://github.com/shakacode/react-webpack-rails-tutorial.

like image 96
Blaine Hatab Avatar answered Oct 24 '22 00:10

Blaine Hatab


I found that it is possible using react-rails in conjunction with browserify-rails. This blog article explains it pretty well.

like image 30
Rick Avatar answered Oct 24 '22 00:10

Rick