Redux::Gem

I Created this gem to add my style of file management using React and Redux to the React_on_Rails gem. Other than the stylesheets components and containers are now self contained and can be re-used easier between projects.

If you have and questions or you'd like to get in contact with me you can contact me through http://www.popwell.com or submit an issue to the github repo.

Create a New Rails project

$ Rails new #projectName

cd into your new project folder open in the editor of your choice

Installation

Add this line to your application's Gemfile:

gem "react_on_rails", "~> 6"
gem 'redux-gem'

And then execute:

$ bundle

Or install it yourself as:

$ gem install redux-gem

Usage

Knowing Redux is not a requirement to use this gem. It is available if you would like to generate containers.

Before you can use the Redux-gem you must install the React_on_Rails gem and run the generator

$ rails generate react_on_rails:install

you won't need to follow any of the other instructions for the React_on_Rails installation when you use the Redux-gem.

for more information on React_on_Rails visit https://github.com/shakacode/react_on_rails#including-your-react-component-in-your-rails-views

Now that React_on_Rails is installed you need to run the Redux-gem start generator

$ rails generate start

This will remove all of the view components and files just created by React_on_Rails and replaces them with the Redux-gem files. It also installs redux, react-redux, react-router, redux-promises to the package.json file. Automatically install the foreman gem. The generator automatically runs npm i && bundle.

To see your app on localhost

$ foreman start -f Procfile.dev

in your browser navigate to http://localhost:5000/ and you should see

                        Redux-gem installed!

To get started, edit client/app/App.jsx and save to reload. edit styles in, app/assets/stylesheets/"component_name".scss

To generate a new component run:

$ rails generate component #component_name

this generates a new component folder inside of the client folder with your components name entered as the class name and the export name. It adds the necessary lines to the registration file allowing your rails app to display them. Creates a Rails view page with the needed render method in views. Adds a scss file to the stylesheets folder with component_name.scss and a simple text-align center added to show it's working. Also, creates a route for your new component.

To generate a new container run:

$ rails generate container #container_name

this generates a new container folder inside of the client folder with your container name entered as the class name and the export name. Creates a #container_name.js, action, constants and reducer. It adds the neccesary lines to the registration file allowing your rails app to display them. Creates a Rails view page with the needed render method in views. Adds a scss file to the stylesheets folder with container_name.scss and a simple text-align center added. Creates a route for your new container.

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.