DEMO APP
This is demonstrates an app working with Rails, React.js, and Alt.
- react-rails gem — for
React.js, ES6 Harmony, and
react_component
mounting helper. - rails-assets — for access to the bower version of Alt.
ES6 Harmony support must be enabled: https://github.com/reactjs/react-rails#jsx
Some notable ES2015 features are missing, like const
and let
.
NOTE: if you config after the Asset Pipeline has its way with your
components, you'll need to run bin/rake assets:clean
or rm -vfr tmp/cache
to
get things working again.
Make sure to instantiate alt before loading stores, actions, etc.
I did this with the following in application.js
:
...
//= require_self
//= require_tree .
var alt = new Alt();
If you want to avoid adding a module system, you'll need to wrap Alt examples in an IIFE. If the Alt docs read something like this:
class NameActions = { ... }
module.exports = alt.createActions(NameActions);
You'll write something like this:
(() => {
class NameActions { ... }
this.NameActions = alt.createActions(NameActions);
})();
NOTE: if you want ES6 syntax available in these files, you'll need to append
.jsx
to the file name. This is a little kludgy but will allow you to work with
the gems you already have installed.