Skip to content

Commit a644607

Browse files
authored
Merge pull request #1279 from reactjs/add-v3-docs
Add v3 docs
2 parents 8c491af + cbf1d26 commit a644607

File tree

3 files changed

+20
-33
lines changed

3 files changed

+20
-33
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ _Please add entries here for your pull requests that are not yet released._
1212
### Breaking Changes
1313
- Remove support & testing for Webpacker 3/4.
1414
- Add support & testing for Shakapacker v6
15-
- Requires separate compilations for server & client bundles (see [Webpack config](https://github.com/reactjs/react-rails/blob/judahmeek/workingCI/test/dummy/config/webpack))
15+
- Requires separate compilations for server & client bundles (see [Webpack config](https://github.com/reactjs/react-rails/tree/master/test/dummy/config/webpack))
1616
- Replaces WebpackManifestContainer, which searched for assets in the webpack manifest, with SeparateServerBundleContainer, which expects a single server bundle file & does not use the webpack manifest at all.
1717
- All in one PR! #1274
1818

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,17 @@ To develop the React_UJS NPM Package, make your changes and run `npm pack` to ma
9494

9595
##### Running tests
9696

97+
Run `yalc publish --push` in the root directory of the gem to ensure the test suites use the exact same js code used in the currenlty developing ReactRails.
98+
9799
`bundle exec appraisal install` to install gems on every gemfile Appraisal contains.
98100
`rake test` or `bundle exec appraisal rake test` runs everything.
99101
or run a specific suite using `bundle exec appraisal <appraisal name> rake test`
100102
- Find appraisal names in [Appraisals](Appraisals)
101103
- Integration tests run in Headless Chrome which is included in Chrome (59+ linux,OSX | 60+ Windows)
102104
- ChromeDriver is included with `chromedriver-helper` gem so no need to manually install that 👍
103105

106+
**Note:** If using Ruby 2.7, set `MT_KWARGS_HACK=1` to ensure Minitest runs smoothly.
107+
104108
##### Updating the pre-bundled react
105109
- Update React with `rake react:update`
106110
It outputs an ironically webpacked couple of files into `lib/assets/react-source/<environment>/react(-server).js` where it will be picked up by `sprockets` in `lib/react/rails/asset_variant.rb`

README.md

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
# React-Rails
1+
# React-Rails v3
22

33
[![Gem](https://img.shields.io/gem/v/react-rails.svg?style=flat-square)](http://rubygems.org/gems/react-rails)
44
[![npm](https://img.shields.io/npm/v/react_ujs.svg?style=flat-square)](https://www.npmjs.com/package/react_ujs)
55
[![Ruby](https://github.com/reactjs/react-rails/actions/workflows/ruby.yml/badge.svg)](https://github.com/reactjs/react-rails/actions/workflows/ruby.yml)
66

77
## News
8-
v2.7.1 is released. Please try it out and report any issues. We'll try to address any critical issues ASAP. We're going shortly release 3.0, which fully support Shakapacker v6, including SSR.
8+
V3.0.0 is released with Shakapacker v6 support, including SSR. Please try it out and report any issues. We'll try to address any critical issues ASAP.
9+
10+
For version 2.7 documentation checkout [2.7-stable](https://github.com/reactjs/react-rails/tree/2.7-stable) branch.
911

1012
## Summary
1113
React-Rails is a flexible tool to use [React](http://facebook.github.io/react/) with Rails. The benefits:
1214
* Automatically renders React server-side and client-side
13-
* Supports Webpacker 4.x, 3.x, 2.x, 1.1+ or Shakapacker v6+
14-
* Supports Sprockets 4.x, 3.x, 2.x
15+
* Supports [Shakapacker](https://github.com/shakacode/shakapacker) v6.x
16+
* Supports Sprockets 4.x, 3.x
1517
* Lets you use [JSX](http://facebook.github.io/react/docs/jsx-in-depth.html), [ES6](http://es6-features.org/), [TypeScript](https://www.typescriptlang.org/), [CoffeeScript](http://coffeescript.org/)
1618

1719
---
@@ -64,10 +66,10 @@ Read the [full review here](https://clutch.co/profile/shakacode#reviews?sort_by=
6466
- [Camelize Props](#camelize-props)
6567
- [Changing Component Templates](#changing-component-templates)
6668
- [Upgrading](#upgrading)
69+
- [2.7 to 3.0](#27-to-30)
6770
- [2.3 to 2.4](#23-to-24)
6871
- [Common Errors](#common-errors)
6972
- [Getting warning for `Can't resolve 'react-dom/client'` in React < 18](#getting-warning-for-cant-resolve-react-domclient-in-react--18)
70-
- [During installation](#during-installation)
7173
- [Undefined Set](#undefined-set)
7274
- [Using TheRubyRacer](#using-therubyracer)
7375
- [HMR](#hmr)
@@ -491,7 +493,7 @@ ReactRailsUJS.detectEvents()
491493

492494
For example, if `Turbolinks` is loaded _after_ `ReactRailsUJS`, you'll need to call this again. This function removes previous handlers before adding new ones, so it's safe to call as often as needed.
493495

494-
If `Turbolinks` is `import`ed via Webpacker (and thus not available globally), `ReactRailsUJS` will be unable to locate it. To fix this, you can temporarily add it to the global namespace:
496+
If `Turbolinks` is `import`ed via Shakapacker (and thus not available globally), `ReactRailsUJS` will be unable to locate it. To fix this, you can temporarily add it to the global namespace:
495497

496498
```js
497499
// Order is particular. First start Turbolinks:
@@ -545,6 +547,7 @@ Server rendering is powered by [`ExecJS`](https://github.com/rails/execjs) and s
545547

546548
- `react-rails` must load your code. By convention, it uses `server_rendering.js`, which was created
547549
by the install task. This file must include your components _and_ their dependencies (eg, Underscore.js).
550+
- Requires separate compilations for server & client bundles (see [Webpack config](https://github.com/reactjs/react-rails/tree/master/test/dummy/config/webpack))
548551
- Your code can't reference `document` or `window`. Prerender processes don't have access to `document` or `window`,
549552
so jQuery and some other libs won't work in this environment :(
550553

@@ -746,6 +749,11 @@ For example, to change the [ES6 Component template](https://github.com/reactjs/r
746749

747750
## Upgrading
748751

752+
### 2.7 to 3.0
753+
- Keep your `react_ujs` up to date: `yarn upgrade`
754+
- **Drop support for Webpacker:** Before any ReactRails upgrade, make sure upgrading from Webpacker to Shakapacker 6.x.
755+
- **SSR:** ReactRails 3.x requires separate compilations for server & client bundles. See [Webpack config](https://github.com/reactjs/react-rails/tree/master/test/dummy/config/webpack) directory in the dummy app to addapt the new implementation.
756+
749757
### 2.3 to 2.4
750758

751759
Keep your `react_ujs` up to date, `yarn upgrade`
@@ -781,30 +789,6 @@ You may see a warning like this when building a Webpack bundle using any version
781789
+ module.exports = merge({}, webpackConfig, ignoreWarningsConfig)
782790
```
783791

784-
### During installation
785-
1) While using installers.(rails webpacker:install:react && rails webpacker:install)
786-
Error:
787-
```
788-
public/packs/manifest.json. Possible causes:
789-
1. You want to set webpacker.yml value of compile to true for your environment
790-
unless you are using the `webpack -w` or the webpack-dev-server.
791-
2. webpack has not yet re-run to reflect updates.
792-
3. You have misconfigured Webpacker's config/webpacker.yml file.
793-
4. Your webpack configuration is not creating a manifest.
794-
or
795-
yarn: error: no such option: --dev
796-
ERROR: [Errno 2] No such file or directory: 'add'
797-
```
798-
Fix: Try updating yarn package.
799-
```
800-
sudo apt remove cmdtest
801-
sudo apt remove yarn
802-
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
803-
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
804-
sudo apt-get update && sudo apt-get install yarn
805-
806-
yarn install
807-
```
808792
### Undefined Set
809793
```
810794
ExecJS::ProgramError (identifier 'Set' undefined):
@@ -820,9 +804,8 @@ TheRubyRacer [hasn't updated LibV8](https://github.com/cowboyd/therubyracer/blob
820804
LibV8 itself is already [beyond version 7](https://github.com/cowboyd/libv8/releases/tag/v7.3.492.27.1) therefore many serverside issues are caused by old JS engines and fixed by using an up to date one such as [MiniRacer](https://github.com/discourse/mini_racer) or [TheRubyRhino](https://github.com/cowboyd/therubyrhino) on JRuby.
821805

822806
### HMR
823-
Hot Module Replacement is [possible with this gem](https://stackoverflow.com/a/54846330/193785) as it does just pass through to Webpacker. Please open an issue to let us know tips and tricks for it to add to the wiki.
824807

825-
Sample repo that shows HMR working with `react-rails`: [https://github.com/edelgado/react-rails-hmr](https://github.com/edelgado/react-rails-hmr)
808+
Check out [Enabling Hot Module Replacement (HMR)](https://github.com/shakacode/shakapacker/blob/master/docs/react.md#enabling-hot-module-replacement-hmr) in Shakapacker documentation.
826809

827810
One caveat is that currently you [cannot Server-Side Render along with HMR](https://github.com/reactjs/react-rails/issues/925#issuecomment-415469572).
828811

0 commit comments

Comments
 (0)