README.md in react-rails-1.7.0 vs README.md in react-rails-1.7.1

- old
+ new

@@ -24,11 +24,11 @@ ## Installation Add `react-rails` to your gemfile: ```ruby -gem 'react-rails', '~> 1.7.0' +gem 'react-rails' ``` And install: ``` @@ -88,21 +88,10 @@ ### JSX After installing `react-rails`, restart your server. Now, `.js.jsx` files will be transformed in the asset pipeline. -`react-rails` currently ships with two transformers, to convert jsx code - - -* `BabelTransformer` using [Babel](http://babeljs.io), which is the default transformer. -* `JSXTransformer` using `JSXTransformer.js` - -You can use the deprecated `JSXTransformer` by setting it in an application config: - -```ruby - config.react.jsx_transformer_class = React::JSX::JSXTransformer -``` - #### BabelTransformer options You can use babel's [transformers](http://babeljs.io/docs/advanced/transformers/) and [custom plugins](http://babeljs.io/docs/advanced/plugins/), and pass [options](http://babeljs.io/docs/usage/options/) to the babel transpiler adding following configurations: @@ -113,22 +102,10 @@ whitelist: ["useStrict"] # even more options } ``` Under the hood, `react-rails` uses [ruby-babel-transpiler](https://github.com/babel/ruby-babel-transpiler), for transformation. -#### JSXTransformer options - -You can use JSX `--harmony` or `--strip-types` options by adding a configuration: - -```ruby -config.react.jsx_transform_options = { - harmony: true, - strip_types: true, # for removing Flow type annotations - asset_path: "path/to/JSXTransformer.js", # if your JSXTransformer is somewhere else -} -``` - ### Rendering & mounting `react-rails` includes a view helper (`react_component`) and an unobtrusive JavaScript driver (`react_ujs`) which work together to put React components on the page. You should require the UJS driver in your manifest after `react` (and after `turbolinks` if you use [Turbolinks](https://github.com/rails/turbolinks)). @@ -145,10 +122,16 @@ and `data-react-props`. If Turbolinks is present components are mounted on the `page:change` event, and unmounted on `page:before-unload`. __Turbolinks >= 2.4.0__ is recommended because it exposes better events. +In case of __Ajax calls__, the UJS mounting can be triggered manually by calling from javascript: + +```javascript +ReactRailsUJS.mountComponents() +``` + The view helper's signature is: ```ruby react_component(component_class_name, props={}, html_options={}) ``` @@ -392,9 +375,13 @@ - `#initialize(options)`, where options is the value passed to `config.react.jsx_transform_options` - `#transform(code_string)` to return a string of transformed code `react-rails` provides two transformers, `React::JSX::JSXTransformer` and `React::JSX::BabelTransformer`. + +### Sprockets 4 + +Support for Sprockets 4.x is currently a work in progress, and not fully featured. Use at your own risk! ### Related Projects - [react\_on\_rails Gem](https://github.com/shakacode/react_on_rails): Webpack Integration of React with Rails utilizing the modern JavaScript tooling and libraries, including Webpack, Babel, React, Redux, React-Router. You can an example of this live at [www.reactrails.com](http://www.reactrails.com). - [React.rb](http://reactrb.org/): Use Ruby to build reactive user interfaces with React under the covers.[github source code here](https://github.com/zetachang/react.rb).