README.md in react_on_rails-9.0.0 vs README.md in react_on_rails-9.0.1

- old
+ new

@@ -1,29 +1,59 @@ [![Build Status](https://travis-ci.org/shakacode/react_on_rails.svg?branch=master)](https://travis-ci.org/shakacode/react_on_rails) [![Codeship Status for shakacode/react_on_rails](https://app.codeship.com/projects/cec6c040-971f-0134-488f-0a5146246bd8/status?branch=master)](https://app.codeship.com/projects/187011) [![Dependency Status](https://gemnasium.com/shakacode/react_on_rails.svg)](https://gemnasium.com/shakacode/react_on_rails) [![Gem Version](https://badge.fury.io/rb/react_on_rails.svg)](https://badge.fury.io/rb/react_on_rails) [![npm version](https://badge.fury.io/js/react-on-rails.svg)](https://badge.fury.io/js/react-on-rails) [![Code Climate](https://codeclimate.com/github/shakacode/react_on_rails/badges/gpa.svg)](https://codeclimate.com/github/shakacode/react_on_rails) [![Coverage Status](https://coveralls.io/repos/shakacode/react_on_rails/badge.svg?branch=master&service=github)](https://coveralls.io/github/shakacode/react_on_rails?branch=master) *If this projects helps you, please give us a star!* [rails/webpacker](https://github.com/rails/webpacker) just shipped 3.0. This now enables me to ship version 9.0. See [PR #908](https://github.com/shakacode/react_on_rails/pull/908) for more details. - # React on Rails v9 is based on Webpacker 3.0! -* See the updated [Tutorial](https://github.com/shakacode/react_on_rails/blob/rails-webpacker/docs/tutorial.md). -* See the [CHANGELOG.md](https://github.com/shakacode/react_on_rails/blob/rails-webpacker/CHANGELOG.md) for migration instructions. +* See the article React on Rails plus Webpacker, Peanut Butter and Jelly for an overview of the integration of React on Rails with Webpacker (article coming soon). +* See the updated [Tutorial](https://github.com/shakacode/react_on_rails/blob/master/docs/tutorial.md). +* See the [CHANGELOG.md](https://github.com/shakacode/react_on_rails/blob/master/CHANGELOG.md) for migration instructions. -## Steps to a New App with rails/webpacker v3 plus React on Rails v9.beta: +---- + +Given that Webpacker already provides React integration, why would you add React on Rails? Additional features of React on Rails include: + +1. Server rendering, often for SEO optimization. +2. Easy passing of props directly from your Rails view to your React components rather than having your Rails view load and then make a separate request to your API. +3. Redux and React-Router integration +4. Localization support +5. Rspec test helpers to ensure your Webpack bundles are ready for tests + +---- + +## Steps to a New App with rails/webpacker v3 plus React on Rails v9: +First be sure to run `rails -v` and check that you are using Rails 5.1.3 or above. If you are using an older version of Rails, you'll need to install webpacker with React per the instructions [here](https://github.com/rails/webpacker). + +### Basic installation + 1. New Rails app: `rails new my-app --webpack=react`. `cd` into the directory. -2. Add beta gem version: `gem 'react_on_rails', '~> 9.0.0.beta.12'` +2. Add gem version: `gem 'react_on_rails', '~> 9.0.1'` 3. Run the generator: `rails generate react_on_rails:install` 4. Start the app: `foreman start -f Procfile.dev` 5. Visit http://localhost:3000/hello_world -Turn on HMR (Hot reloading) +### Turn on HMR (Hot reloading) + 1. Edit `config/webpacker.yml` and set `hmr: true` 2. Start the app: `foreman start -f Procfile.dev-server` 3. Visit http://localhost:3000/hello_world 4. Edit `app/javascript/bundles/HelloWorld/components/HelloWorld.jsx`, hit save, and see the screen update. +### Turn on server rendering + +*Does not work with hot reloading, yet, per [Webpacker issue #732](https://github.com/rails/webpacker/issues/732)* + +1. Edit `app/views/hello_world/index.html.erb` and set `prerender` to `true`. +2. Refresh the page. + +This is the line where you turn server rendering on by setting prerender to true: + +``` +<%%= react_component("HelloWorld", props: @hello_world_props, prerender: false) %> +``` + --------------- ## Thank you from Justin Gordon and [ShakaCode](http://www.shakacode.com) Thank you for considering using [React on Rails](https://github.com/shakacode/react_on_rails). @@ -93,13 +123,13 @@ * [284 Ruby Rogues: React on Rails with Justin Gordon and Rob Wise](https://devchat.tv/ruby-rogues/284-rr-react-on-rails-with-justin-gordon-and-rob-wise) ------ # NEWS -* **[VERSION 9.0.0.beta (branch)](https://github.com/shakacode/react_on_rails/tree/rails-webpacker) shipped!** This version depends on Webpacker directly. See the [CHANGELOG.md](https://github.com/shakacode/react_on_rails/blob/rails-webpacker/CHANGELOG.md) for migration instructions. +* 2017-09-06: **VERSION 9.0.0 shipped!** This version depends on Webpacker directly. See the [CHANGELOG.md](https://github.com/shakacode/react_on_rails/blob/master/CHANGELOG.md) for migration instructions. * [VERSION 8.1.0](https://rubygems.org/gems/react_on_rails/) shipped with [webpacker_lite](https://github.com/shakacode/webpacker_lite) (soon [**webpacker**](https://github.com/rails/webpacker/issues/464#issuecomment-310986140) support! [react-webpack-rails-tutorial PR #395](https://github.com/shakacode/react-webpack-rails-tutorial/pull/395) shows the changes needed to migrate from the Asset Pipeline to Webpacker Lite. For more information, see my article: [Webpacker Lite: Why Fork Webpacker?](https://blog.shakacode.com/webpacker-lite-why-fork-webpacker-f0a7707fac92). Per recent discussions, we [will merge Webpacker Lite changes back into Webpacker](https://github.com/rails/webpacker/issues/464#issuecomment-310986140). There's no reason to wait for this. The upgrade will eventually be trivial. -* The Docs here on `master` refer to 8.1.0 including support for [webpacker_lite](https://github.com/shakacode/webpacker_lite). The docs on [on the 9.0.0 beta branch](https://github.com/shakacode/react_on_rails/tree/rails-webpacker) refer to using Webpacker rather than Webpacker Lite. +* The Docs here on `master` refer to 9.x including support for [rails/webpacker](https://github.com/rails/webpacker). *Use the [7.0.4 docs](https://github.com/shakacode/react_on_rails/tree/7.0.4) to refer to the older asset pipeline way.* * *See [NEWS.md](NEWS.md) for more notes over time.* ------ @@ -250,14 +280,14 @@ React on Rails provides an option for automatic conversions of Rails `*.yml` locale files into `*.js` files for `react-intl`. See the [How to add I18n](docs/basics/i18n.md) for a summary of adding I18n. ## NPM -All JavaScript in React On Rails is loaded from npm: [react-on-rails](https://www.npmjs.com/package/react-on-rails). To manually install this (you did not use the generator), assuming you have a standard configuration, run this command: +All JavaScript in React On Rails is loaded from npm: [react-on-rails](https://www.npmjs.com/package/react-on-rails). To manually install this (you did not use the generator), assuming you have a standard configuration, run this command (assuming you are in the directory where you have your `node_modules`): ```bash -cd client && yarn add react-on-rails +yarn add react-on-rails ``` That will install the latest version and update your package.json. ## Webpacker Configuration @@ -604,11 +634,9 @@ If you want to use a node server for server rendering, [get in touch](mailto:justin@shakacode.com). ShakaCode has built a premium Node rendering server for React on Rails. ## Additional Documentation **Try out our new [Documentation Gitbook](https://shakacode.gitbooks.io/react-on-rails/content/) for improved readability & reference!** -+ **Webpacker Lite** - + [Webpacker Lite: Why Fork Webpacker?](https://blog.shakacode.com/webpacker-lite-why-fork-webpacker-f0a7707fac92) + **Rails** + [Rails Assets](./docs/additional-reading/rails-assets.md) + [Rails Engine Integration](./docs/additional-reading/rails-engine-integration.md) + [Rails View Rendering from Inline JavaScript](./docs/additional-reading/rails_view_rendering_from_inline_javascript.md)