All notable changes to this project's source code will be documented in this file. Items under Unreleased
is upcoming features that will be out in the next version.
Migration instructions for the major updates can be found here. Some smaller migration information can be found here.
If you would like help in migrating between React on Rails versions or help with implementing server rendering, please contact justin@shakacode.com for information about our React on Rails Pro Support Options.
We specialize in helping companies quickly and efficiently update client-side dependencies, allowing developers to focus on features and bug fixes rather than addressing tech-debt from old dependencies. ShakaCode also maintains Shakapacker, the successor to Webpacker.
Please follow the recommendations outlined at keepachangelog.com. Please use the existing headings and styling as a guide, and add a link for the version diff at the bottom of the file. Also, please update the Unreleased
link to compare to the latest release version.
Changes since the last non-beta release.
-
Fixed Typescript types for ServerRenderResult, ReactComponent, RenderFunction, and RailsContext interfaces. PR 1582 & PR 1585 by kotarella1110
-
Removed a workaround in
JsonOutput#escape
for an no-longer supported Rails version. Additionally, removedUtils.rails_version_less_than_4_1_1
which was only used in the workaround. PR 1580 by wwahammy
- Exposed TypeScript all types PR 1586 by kotarella1110
13.4.0 - 2023-07-30
- Fixed Pack Generation logic during
assets:precompile
ifauto_load_bundle
isfalse
&components_subdirectory
is not set. PR 1567 by blackjack26 & judahmeek.
- Throw error when attempting to redefine ReactOnRails. PR 1562 by rubenochiavone.
- Prevent generating FS-based packs when
component_subdirectory
configuration is not present. PR 1567 by blackjack26. - Removed a requirement for autoloaded pack files to be generated as part of CI or deployment separate from initial Shakapacker bundling. PR 1545 by judahmeek.
13.3.5 - 2023-05-31
- Fixed race condition where a react component could attempt to initialize before it had been registered. PR 1540 by judahmeek.
13.3.4 - 2023-05-23
- Improved functionality of Filesystem-based pack generation & auto-bundling. Added
make_generated_server_bundle_the_entrypoint
configuration key. PR 1531 by judahmeek.
13.3.3 - 2023-03-21
13.3.2 - 2023-02-24
- Fixed the bug in
bin/dev
andbin/dev-static
scripts by usingsystem
instead ofexec
and remove option to pass arguments PR 1519 by ahangarha.
13.3.1 - 2023-01-30
- Optimized
ReactOnRails::TestHelper
's RSpec integration usingwhen_first_matching_example_defined
. PR 1496 by mcls.
13.3.0 - 2023-01-29
- Fixed pack not found warning while using
react_component
andreact_component_hash
helpers, even when corresponding chunks are present. PR 1511 by pulkitkkr. - Fixed FS-based packs generation functionality to trigger pack generation on the creation of a new react component inside
components_subdirectory
. PR 1506 by pulkitkkr. - Upgrade several JS dependencies to fix security issues. PR 1514 by ahangarha.
- Added
./bin/dev
and./bin/dev-static
executables to ease and standardize running the dev server. PR 1491 by ahangarha.
13.2.0 - 2022-12-23
- Fix reactOnRailsPageUnloaded when there is no component on the page. Important for apps using both hotwire and react_on_rails. PR 1498 by NhanHo.
- Fixing wrong type. The throwIfMissing param of getStore should be optional as it defaults to true. PR 1480 by wouldntsavezion.
13.1.0 - 2022-08-20
-
Removed addition of
mini_racer
gem by default. PR 1453 by vtamara and tomdracz.Using
mini_racer
makes most sense when deploying or building in environments that do not have Javascript runtime present. Sincereact_on_rails
requires Node.js, there's no reason to overrideExecJS
runtime withmini_racer
.To migrate this change, remove
mini_racer
gem from yourGemfile
and test your app for correct behaviour. You can continue usingmini_racer
and it will be still picked as the defaultExecJS
runtime, if present in your appGemfile
. -
Upgraded the example test app in
spec/dummy
to React 18. PR 1463 by alexeyr. -
Added file-system-based automatic bundle generation feature. PR 1455 by pulkitkkr.
-
Fixed the
You are importing hydrateRoot from "react-dom" [...] You should instead import it from "react-dom/client"
warning under React 18 (#1441). PR 1460 by alexeyr.In exchange, you may see a warning like this when building using any version of React below 18:
WARNING in ./node_modules/react-on-rails/node_package/lib/reactHydrateOrRender.js19:25-52 Module not found: Error: Can't resolve 'react-dom/client' in '/home/runner/work/react_on_rails/react_on_rails/spec/dummy/node_modules/react-on-rails/node_package/lib' @ ./node_modules/react-on-rails/node_package/lib/ReactOnRails.js 34:45-78 @ ./client/app/packs/client-bundle.js 5:0-42 32:0-23 35:0-21 59:0-26
It can be safely suppressed in your Webpack configuration.
13.0.2 - 2022-03-09
- React 16 doesn't support version property, causing problems loading React on Rails. PR 1435 by justin808.
13.0.1 - 2022-02-09
13.0.0 - 2022-02-08
- Removed webpacker as a dependency. Add gem Shakapacker to your project, and update your package.json to also use shakapacker.
- Proper throwing of exceptions.
- Default configuration better handles test env.
12.6.0 - 2022-01-22
- A
rendering_props_extension
configuration which takes a module with anadjust_props_for_client_side_hydration
method, which is used to process props differently for server/client ifprerender
is set totrue
. PR 1413 by gscarv13 & judahmeek.
12.5.2 - 2021-12-29
- Usage of config.build_production_command for custom command for production builds fixed. PR 1415 by judahmeek.
12.5.1 - 2021-12-27
- A fatal server rendering error if running an ReactOnRails >=12.4.0 with ReactOnRails Pro <2.4.0. PR 1412 by judahmeek.
12.5.0 - 2021-12-26
- Support for React 18, including the changed SSR API. PR 1409 by kylemellander.
- Added webpack configuration files as part of the generator and updated webpacker to version 6. PR 1404 by gscarv13.
- Supports Rails 7.
- Changed logic of determining the usage of the default rails/webpacker webpack config or a custom command to only check if the config.build_production_command is defined. PR 1402 by justin808 and gscarv13.
- Minimimum required Ruby is 2.7 to match lastest rails/webpacker.
12.4.0 - 2021-09-22
-
ScoutAPM tracing support for server rendering PR 1379 by justin808.
-
Ability to stop React on Rails from modifying or creating the
assets:precompile
task. PR 1371 by justin808. Thanks to elstgav for the suggestion! -
Added the ability to have render functions return a promise to be awaited by React on Rails Pro Node Renderer. PR 1380 by judahmeek
12.3.0 - 2021-07-26
-
Ability to use with Turbo (@hotwired/turbo), as Turbolinks gets obsolete. PR 1374 by pgruener and PR 1377 by mdesantis.
To configure turbo the following option can be set:
ReactOnRails.setOptions({ turbo: true })
12.2.0 - 2021-03-25
- Ability to configure server react rendering to throw rather than just logging the error. Useful for React on Rails Pro Node rendering PR 1365 by justin808.
12.1.0 - 2021-03-23
- Added the ability to assign a module with a
call
method toconfig.build_production_command
. See the configuration docs. PR 1362: Accept custom module for config.build_production_command.
- Stop setting NODE_ENV value during precompile, as it interferred with rails/webpacker's setting of NODE_ENV to production by default. Fixes #1334. PR 1356: Don't set NODE_ENV in assets.rake by alexrozanski.
12.0.4 - 2020-11-14
- Install generator now specifies the version. Fixes React on Rails Generator installs the older npm package #1336. PR 1338: Fix Generator to use Exact NPM Version by justin808.
12.0.3 - 2020-09-20
- Async script loading optimizes page load speed. With this fix, a bundle can be loaded "async" and a handler function can determine when to hydrate. For an example of this, see the docs for loadable-components SSR. PR 1327 by justin808. Loadable-Components is supported by React on Rails Pro.
12.0.2 - 2020-07-09
12.0.1 - 2020-07-09
- Changed invocation of webpacker:clean to use a very large number of versions so it does not acidentally delete the server-bundle.js. PR 1306 by By justin808.
12.0.0 - 2020-07-08
For upgrade instructions, see docs/guides/upgrading-react-on-rails.md.
- React Hooks Support for top level components
- Typescript bindings
- rails/webpacker "just works" with React on Rails by default.
- i18n support for generating a JSON file rather than a JS file.
In order to solve the issues regarding React Hooks compatibility, the number of parameters
for functions is used to determine if you have a generator function that will get invoked to
return a React component, or you are registering a functional React component. Alternately, you can
set JavaScript property renderFunction
on the function for which you want to return to be
invoked to return the React component. In that case, you won't need to pass any unused params.
PR 1268 by justin808
See docs/guides/upgrading-react-on-rails for details.
-
react_on_rails
fully supportsrails/webpacker
. The example test app inspec/dummy
was recently converted over to use rails/webpacker v4+. It's a good example of how to leverage rails/webpacker's webpack configuration for server-side rendering. -
Changed the precompile task to use the rails/webpacker one by default
-
Updated generators to use React hooks
-
Requires the use of rails/webpacker view helpers
-
If the webpacker webpack config files exist, then React on Rails will not override the default assets:precompile setup by rails/webpacker. If you are not using the rails/webpacker setup for webpack, then be sure to remove the JS files inside of config/webpack, like
config/webpack/production.js.
-
Removed env_javascript_include_tag and env_stylesheet_link_tag as these are replaced by view helpers from rails/webpacker
-
Removal of support for old Rubies and Rails.
-
Removal of config.symlink_non_digested_assets_regex as it's no longer needed with rails/webpacker. If any business needs this, we can move the code to a separate gem.
-
Added configuration option
same_bundle_for_client_and_server
with defaultfalse
because- Production applications would typically have a server bundle that differs from the client bundle
- This change only affects trying to use HMR with react_on_rails with rails/webpacker.
The previous behavior was to always go to the webpack-dev-server for the server bundle if the webpack-dev-server was running and the server bundle was found in the
manifest.json
.If you are using the same bundle for client and server rendering, then set this configuration option to
true
. By justin808. -
Added support to export locales in JSON format. New option added
i18n_output_format
which allows to specify locales format eitherJSON
orJS
.JSON
format is now the default.Use this config setting to get the old behavior: config.i18n_output_format = 'js'
PR 1271 by ashgaliyev.
- Added Typescript definitions to the Node package. By justin808 and judahmeek in PR 1287.
- Removed restriction to keep the server bundle in the same directory with the client bundles. Rails/webpacker 4 has an advanced cleanup that will remove any files in the directory of other webpack files. Removing this restriction allows the server bundle to be created in a sibling directory. By justin808.
11.3.0 - 2019-05-24
-
Added method for retrieving any option from
render_options
PR 1213 by ashgaliyev. -
html_options has an option for 'tag' to set the html tag name like this:
html_options: { tag: "span" }
. PR 1208 by tahsin352.
11.2.2 - 2018-12-24
- rails_context can more easily be called from controller methods. The mandatory param of server_side has been made optional.
11.2.1 - 2018-12-06
- If using React on Rails Pro, upgrade react_on_rails_pro to a version >= 1.3.
-
To support React v16, updated API for manually calling
ReactOnRails.render(name, props, domNodeId, hydrate)
. Added 3rd @param hydrate Pass truthy to update server rendered html. Default is falsey Any truthy values calls hydrate rather than render. PR 1159 by justin808 and coopersamuel. -
Enabled the use of webpack-dev-server with Server-side rendering. PR 1173 by justin808 and judahmeek.
-
Changed the default for:
config.raise_on_prerender_error = Rails.env.development?
Thus, developers will need to fix server rendering errors before continuing. PR 1145 by justin808.
Do not use. Unpublished. Caused by an issue with the release script.
11.1.8 - 2018-10-14
- Improved tutorial and support for HMR when using
rails/webpacker
for Webpack configuration. PR 1156 by justin808.
11.1.7 - 2018-10-10
- Fixed bug where intl parsing would fail when trying to parse integers or blank entries. by sepehr500
11.1.6 - 2018-10-05
- Fix client startup invoking render prematurely, AGAIN. Fix additional cases of client startup failing during interactive readyState". Closes issue #1150. PR 1152 by rakelley.
11.1.5 - 2018-10-03
- Fix client startup invoking render prematurely. Closes issue #1150. PR 1151 by rakelley.
11.1.4 - 2018-09-12
- Ignore Arrays in Rails i18n yml files. PR 1129 by vcarel.
- Fix to apply transform-runtime. And work with Babel 6 and 7. (Include revert of PR 1136) PR 1140 by Ryunosuke Sato.
- Upgrade Babel version to 7 PR 1141 by Ryunosuke Sato.
11.1.3 - 2018-08-26
- Don't apply babel-plugin-transform-runtime inside react-on-rails to work with babel 7. PR 1136 by Ryunosuke Sato.
- Add support for webpacker 4 prereleases. PR 1134 by Judahmeek)
11.1.2 - 2018-08-18
- Tests now properly exit if the config.build_test_command fails!
- Source path for project using Webpacker would default to "app/javascript" even if when the node_modules directory was set to "client". Fix now makes the configuration of this crystal clear.
- renamed method RenderOptions.has_random_dom_id? to RenderOptions.random_dom_id? for rubocop rule. PR 1133 by justin808
11.1.1 - 2018-08-09
TRUE
was deprecated in ruby 2.4, usingtrue
instead. PR 1128 by Aguardientico.
11.1.0 - 2018-08-07
- Add random dom id option. This new global and react_component helper option allows configuring whether or not React on Rails will automatically add a random id to the DOM node ID. PR 1121 by justin808
- Added configuration option random_dom_id
- Added method RenderOptions has_random_dom_id?
- Fix invalid warn directive. PR 1123 by mustangostang.
11.0.10 - 2018-07-22
- Much better logging of rendering errors when there are lots of props. Only the a 1,000 chars are logged, and the center is indicated to be truncated. PR 1117 and PR 1118 by justin808.
- Properly clearing hydrated stores when server rendering. PR 1120 by squadette.
11.0.9 - 2018-06-24
- Handle <script async> for Webpack bundle transparently. Closes issue #290 PR 1099 by squadette. Merged in PR 1107.
11.0.8 - 2018-06-15
- HashWithIndifferent access for props threw if used for props. PR 1100 by justin808.
- Test helper for detecting stale bundles did not properly handle the case of a server-bundle.js without a hash.PR 1102 by justin808.
- Fix test helper determination of stale assets. PR 1093 by justin808.
- Document how to manually rehydrate XHR-substituted components on client side. PR 1095 by hchevalier.
11.0.7 - 2018-05-16
11.0.6 - 2018-05-15
- Even more detailed errors for Honeybadger and Sentry when there's a JSON parse error on server rendering. PR 1086 by justin808.
11.0.5 - 2018-05-11
11.0.4 - 2018-05-3
- Throw if configuration.generated_assets_dir specified, and using webpacker, and if that doesn't match the public_output_path. Otherwise, warn if generated_assets_dir is specified
- Fix the setup for tests for spec/dummy so they automatically rebuild by correctly setting the source_path in the webpacker.yml
- Updated documentation for the testing setup.
- Above in PR 1072 by justin808.
react_component_hash
has implicitprerender: true
because it makes no sense to have react_component_hash not use prerrender. Improved docs onreact_component_hash
. Also, fixed issue where checking gem existence. PR 1077 by justin808.
11.0.3 - 2018-04-24
- Fixed issue with component script initialization when using react_component_hash. PR 1071 by jblasco3.
11.0.2 - 2018-04-24
11.0.1 - 2018-04-23
11.0.0 - 2018-04-21
- Unused
server_render_method
was removed from the configuration. If you want to use a custom renderer, contact justin@shakacode.com. We have a custom node rendering solution in production for egghead.io. - Removed ReactOnRails::Utils.server_bundle_file_name and ReactOnRails::Utils.bundle_file_name. These are part of the performance features of "React on Rails Pro".
- Removed ENV["TRACE_REACT_ON_RAILS"] usage and replacing it with config.trace.
- Tracing (debugging) options are simplified with a single
config.trace
setting that defaults to true for development and false otherwise. - Calls to setTimeout, setInterval, clearTimeout will now always log some message if config.trace is true. Your JavaScript code should not be calling setTimout when server rendering.
- Errors raised are of type ReactOnRailsError, so you can see they came from React on Rails for debugging.
- Removed ReactOnRails::Utils.server_bundle_file_name and ReactOnRails::Utils.bundle_file_name.
- No longer logging the
railsContext
when server logging. - Rails.env is provided in the default railsContext, as suggested in issue #697. PR 1065 by justin808.
- More exact version checking. We keep the react_on_rails gem and the react-on-rails node package at the same exact versions so that we can be sure that the interaction between them is precise. This is so that if a bug is detected after some update, it's critical that both the gem and the node package get the updates. This change ensures that the package.json specification does not use a ~ or ^ as reported in issue #1062. PR 1063 by justin808.
- Sprockets: Now use the most recent manifest when creating symlinks. See issue #1023. PR 1064 by justin808.
10.1.4 - 2018-04-11
-
Changed i18n parsing to convert ruby i18n argument syntax into FormatJS argument syntax. PR 1046 by sepehr500.
-
Fixed an issue where the spec compiler check would fail if the project path contained spaces. PR 1045 by andrewmarkle.
-
Updated the default
build_production_command
that caused production assets to be built with development settings. PR 1053 by Roman Kushnir.
10.1.3 - 2018-02-28
- Improved error reporting on version mismatches between Javascript and Ruby packages. PR 1025 by theJoeBiz.
10.1.2 - 2018-02-27
- Use ReactDOM.hydrate() for hydrating a SSR component if available. ReactDOM.render() has been deprecated for use on SSR components in React 16 and this addresses the warning. PR 1028 by theJoeBiz.
10.1.1 - 2018-01-26
10.1.0 - 2018-01-23
- Added 2 cache helpers: ReactOnRails::Utils.bundle_file_name(bundle_name) and ReactOnRails::Utils.server_bundle_file_name for easy access to the hashed filenames for use in cache keys. PR 1018 by justin808.
- Use redux component in generated redux Hello World example: PR 1006 by lewaabahmad.
- Fixed
Utils.bundle_js_file_path
generating the incorrect path formanifest.json
in webpacker projects: Issue #1011 by elstgav
10.0.2 - 2017-11-10
- Remove unnecessary dependencies from released NPM package: PR 968 by tricknotes.
10.0.1 - 2017-10-28
- Fixed
react_component_hash
functionality in cases of prerendering errors: PR 960 by Judahmeek. - Fix to add missing dependency to run generator spec individually: PR 962 by tricknotes.
- Fixes check for i18n_dir in LocalesToJs returning false when i18n_dir was set. PR 899 by hakongit.
- Fixed mistake in rubocop comments that led to errors when handling exceptions in ReactOnRails::ServerRendering::Exec PR 963 by railsme.
- Fixed and improved I18n directories checks: PR 967 by railsme
10.0.0 - 2017-10-08
- Created
react_component_hash
method for react_helmet support.
- Deprecated
react_component
functionality for react_helmet support. To clarify, the method itself is not deprecated, only certain functionality which has been moved toreact_component_hash
PR 951 by Judahmeek.
9.0.3 - 2017-09-20
9.0.2 - 2017-09-10
9.0.1 - 2017-09-10
9.0.0 - 2017-09-06
Updated React on Rails to depend on rails/webpacker. PR 908 by justin808.
Moved to our documentation.
8.0.7 - 2017-08-16
- Fixes generator bug by keeping blank line at top in case existing .gitignore does not end in a newline. #916 by justin808.
8.0.6 - 2017-07-19
- Fixes server rendering when using a CDN. Server rendering would try to fetch a file with the "asset_host". This change updates the webpacker_lite dependency to 2.1.0 which has a new helper
pack_path
. #901 by justin808. Be sure to update webpacker_lite to 2.1.0. - The package.json file created by the generator now creates minified javascript production builds by default. This was done by adding the -p flag to webpack on the build:production script. #895 by serodriguez68
- Fixes GitUtils.uncommitted_changes? throwing an error when called in an environment without Git, and allows install generator to be run successfully with
--ignore-warnings
#878 by jasonblalock.
8.0.5 - 2017-07-04
- Corrects
devBuild
value for webpack production build from webpackConfigLoader. #877 by chenqingspring. - Remove contentBase deprecation warning message. #878 by ened .
- Removes invalid reference to _railsContext in the generated files. #886 by justin808.
- All tests run against Rails 5.1.2
Note: 8.0.4 skipped.
8.0.3 - 2017-06-19
- Ruby 2.1 issue due to
<<~
as reported in issue #870. #867 by justin808
8.0.2 - 2017-06-04
- Any failure in webpack to build test files quits tests.
- Fixed a Ruby 2.4 potential crash which could cause a crash due to pathname change in Ruby 2.4.
- CI Improvements:
- Switched to yarn link and removed relative path install of react-on-rails
- Removed testing of Turbolinks 2
- All tests run against Rails 5.1.1
- Fixed test failures against Ruby 2.4
- #862 by justin808
8.0.1 - 2017-05-30
8.0.0 - 2017-05-29
- Generators and full support for webpacker_lite
- No breaking changes to move to 8.0.0 other than the default for this setting changed to nil. If you depended on the default of this setting and are using the asset pipeline (and not webpacker_lite), then add this to your
config/initializers/react_on_rails.rb
:symlink_non_digested_assets_regex: /\.(png|jpg|jpeg|gif|tiff|woff|ttf|eot|svg|map)/,
- For an example of migration, see: react-webpack-rails-tutorial PR #395
- For a simple example of the webpacker_lite setup, run the basic generator.
8.0.0-beta.3 - 2017-05-27
- Major updates for WebpackerLite 2.0.2. #844 by justin808 with help from ](https://github.com/robwise)
- Logging no longer occurs when trace is turned to false. #845 by conturbo
8.0.0-beta.2 - 2017-05-08
Removed unnecessary values in default paths.yml files for generators. #834 by justin808.
8.0.0-beta.1 - 2017-05-03
Support for WebpackerLite in the generators. #822 by kaizencodes and justin808.
Breaking change is that the default value of symlink_non_digested_assets_regex has changed from this old value to nil. This is a breaking change if you didn't have this value set in your config/initializers/react_on_rails.rb file and you need this because you're using webpack's CSS features and you have not switched to webpacker lite.
symlink_non_digested_assets_regex: /\.(png|jpg|jpeg|gif|tiff|woff|ttf|eot|svg|map)/,
7.0.4 - 2017-04-27
7.0.3 - 2017-04-27
Same as 7.0.1.
Accidental release of beta gem here
7.0.1 - 2017-04-27
7.0.0 - 2017-04-25
6.10.1 - 2017-04-23
- Improve json conversion with tests and support for older Rails 3.x. #787 by cheremukhin23 and Ynote.
6.10.0 - 2017-04-13
- Add an ability to return multiple HTML strings in a
Hash
as a result ofreact_component
method call. Allows to build<head>
contents with React Helmet. #800 by udovenko.
6.9.3 - 2017-04-03
6.9.2 - 2017-04-02
- Update version_checker.rb to
logger.error
rather thanlogger.warn
for gem/npm version mismatch. #788 by justin808.
- Remove pretty formatting of JSON in development. #789 by justin808
- Clear hydrated stores with each server rendered block. #785 by udovenko
6.9.1 - 2017-03-30
6.9.0 - 2017-03-29
- Use <script type="application/json"> for props and store instead of hidden div. [#775] (shakacode#775) by cheremukhin23.
- Add option to specify i18n_yml_dir in order to include only subset of locale files when generating translations.js & default.js for react-intl. #777 by danijel.
6.8.2 - 2017-03-24
- Change webpack output path to absolute and update webpack to version ^2.3.1. #771 by cheremukhin23.
6.8.1 - 2017-03-21
- Fixed error "The node you're attempting to unmount was rendered by another copy of React." #706 when navigating to cached page using Turbolinks #763 by szyablitsky.
6.8.0 - 2017-03-06
6.7.2 - 2017-03-05
- Improve i18n Integration with a better error message if the value of the i18n directory is invalid. #748 by justin808.
6.7.1 - 2017-02-28
No changes other than a test fix.
6.7.0 - 2017-02-28
- If you installed 6.6.0, you will need to comment out the line matching i18n_dir unless you are using this feature. 6.7.1 will give you an error like:
Errno::ENOENT: No such file or directory @ rb_sysopen - /tmp/build_1444a5bb9dd16ddb2561c7aff40f0fc7/my-app-816d31e9896edd90cecf1402acd002c724269333/client/app/libs/i18n/translations.js
Commenting out this line addresses the issue:
config.i18n_dir = Rails.root.join("client", "app", "libs", "i18n")
- Allow using rake task to generate javascript locale files. The test helper automatically creates the localization files when needed. #717 by JasonYCHuang.
- Upgrade Rails to 4.2.8 to fix security vulnerabilities in 4.2.5. #735 by hrishimittal.
- Fix spec failing due to duplicate component. #734 by hrishimittal.
6.6.0 - 2017-02-18
6.5.1 - 2017-02-11
- Allow using gem without sprockets. #671 by fc-arny.
- Fixed issue #706 with "flickering" components when they are unmounted too early #709 by szyablitsky.
- Small formatting fix for errors #703 by justin808.
6.5.0 - 2017-01-31
- Allow generator function to return Object with property
renderedHtml
(already could return Object with propsredirectLocation, error
) rather than a React component or a function that returns a React component. One reason to use a generator function is that sometimes in server rendering, specifically with React Router v4, you need to return the result of calling ReactDOMServer.renderToString(element). #689 by justin808.
- Fix incorrect "this" references of Node.js SSR #690 by nostophilia.
6.4.2 - 2017-01-17
- Added OS detection for install generator, system call for Windows and unit-tests for it. #666 by GeorgeGorbanev.
6.4.1 - 2017-1-17
No changes.
6.4.0 - 2017-1-12
- Since foreman is no longer a dependency of the React on Rails gem, please run
gem install foreman
. If you are using rvm, you may wish to runrvm @global do gem install foreman
to install foreman for all your gemsets.
- Automatically generate i18n javascript files for
react-intl
when the serve starts up. #642 by JasonYCHuang.
6.3.5 - 2017-1-6
- The redux generator now creates a HelloWorld component that uses redux rather than local state. #669 by justin808.
6.3.4 - 2016-12-25
6.3.3 - 2016-12-25
- By using the hook on
turbolinks:before-visit
to unmount the components, we can ensure that components are unmounted even when Turbolinks cache is disabled. Previously, we usedturbolinks:before-cache
event hook. #644 by volkanunsal. - Added support for Ruby 2.0 #651 by bbonamin.
6.3.2 - 2016-12-5
- The
react_component
method was raising aNameError
whenReactOnRailsHelper
was included in a plain object. #636 by jtibbertsma. - "Node parse error" for node server rendering. #641 by alleycat-at-git and rocLv
- Better error handling when the react-on-rails node package entry is missing.#602 by benjiwheeler.
6.3.1 - 2016-11-30
6.3.0 - 2016-11-30
-
Modified register API to allow registration of renderers, allowing a user to manually render their app to the DOM. This allows for code splitting and deferred loading. #581 by jtibbertsma.
-
Updated Basic Generator & Linters. Examples are simpler. #624 by Judahmeek.
-
Slight improvement to the 'no hydrated stores' error. #605 by cookiefission.
6.2.1 - 2016-11-19
-
Removed unnecesary passing of context in the HelloWorld Container example and basic generator. #612 by justin808
-
Turbolinks 5 bugfix to use
before-cache
, notbefore-render
. #611 by volkanunsal.
6.2.0 - 2016-11-19
- Updated the generator templates to reflect current best practices, especially for the redux version. #584 by nostophilia.
6.1.2 - 2016-10-24
- Added compatibility with older manifest.yml files produced by Rails 3 Sprockets when symlinking digested assets during precompilation #566 by etripier.
6.1.1 - 2016-09-09
- React on Rails was incorrectly failing to create symlinks when a file existed in the location for the new symlink. #491 by robwise and justin808.
6.1.0 - 2016-08-21
- Node option for installer added as alternative for server rendering #469 by jbhatab.
- Server rendering now supports contexts outside of browser rendering, such as ActionMailer templates #486 by eacaps.
- Added authenticityToken() and authenticityHeaders() javascript helpers for easier use when working with CSRF protection tag generated by Rails #517 by dzirtusss.
- Updated JavaScript error handling on the client side. Errors in client rendering now pass through to the browser #521 by dzirtusss.
- React on Rails now correctly parses single-digit version strings from package.json #491 by samphilipd .
- Fixed assets symlinking to correctly use filenames with spaces. Begining in #510, ending in #513 by dzirtusss.
- Check encoding of request's original URL and force it to UTF-8 #527 by lucke84
6.0.5 - 2016-07-11
6.0.4 - 2016-06-13
6.0.3 - 2016-06-07
- Added assets symlinking support on Heroku #446 by Alexey Karasev.
6.0.2 - 2016-06-06
- Fix colisions in ids of DOM nodes generated by
react_component
by indexing in using an UUID rather than an auto-increment value. This means that it should be overriden using theid
parameter ofreact_component
if one wants to generate a predictable id (e.g. for testing purpose). See Issue #437. Fixed in #438 by Michael Baudino.
6.0.1 - 2016-05-27
- Allow for older version of manifest.json for older versions of sprockets. See Issue #435. Fixed in #436 by alleycat-at-git.
6.0.0 - 2016-05-25
-
Added automatic compilation of assets at precompile is now done by ReactOnRails. Thus, you don't need to provide your own assets.rake file that does the precompilation. #398 by robwise, jbhatab, and justin808.
-
Migration to v6
-
Do not run the generator again if you've already run it.
-
See shakacode/react-webpack-rails-tutorial/pull/287 for an example of upgrading from v5.
-
To configure the asset compliation you can either
- Specify a
config/react_on_rails
setting forbuild_production_command
to be nil to turn this feature off. - Specify the script command you want to run to build your production assets, and remove your assets.rake file.
- Specify a
-
If you are using the ReactOnRails test helper, then you will need to add the 'config.npm_build_test_command' to your config to tell react_on_rails what command to run when you run rspec.
-
-
See shakacode/react-webpack-rails-tutorial #287 for an upgrade example. The PR has a few comments on the upgrade.
Here is the addition to the generated config file:
# This configures the script to run to build the production assets by webpack. Set this to nil
# if you don't want react_on_rails building this file for you.
config.build_production_command = "npm run build:production"
# If you are using the ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
# with rspec then this controls what npm command is run
# to automatically refresh your webpack assets on every test run.
config.npm_build_test_command = "npm run build:test"
- Fixed errors when server rendered props contain \u2028 or \u2029 characters #375 by mariusandra
- Fixed "too early unmount" which caused problems with Turbolinks 5 not updating the screen #425 by szyablitsky
- Experimental ability to use node.js process for server rendering. See #380 by alleycat-at-git.
- Non-digested version of assets in public folder #413 by alleycat-at-git.
- Cache client/node_modules directory to prevent Heroku from reinstalling all modules from scratch #324 by modosc.
- ReactOnRails.reactOnRailsPageLoaded() is exposed in case one needs to call this manually and information on async script loading added. See #315 by SqueezedLight.
- #398 by robwise, jbhatab, and justin808 contains:
- Only one webpack config is generated for server and client config. Package.json files were changed to reflect this.
- Added npm_build_test_command to allow developers to change what npm command is automatically run from rspec.
- Replace URI with Addressable gem. See #405 by lucke84
- #398 by robwise, jbhatab, and justin808 contains:
- Server rendering is no longer an option in the generator and is always accessible.
- Removed lodash, jquery, and loggerMiddleware from the generated code.
- Removed webpack watch check for test helper automatic compilation.
5.2.0 - 2016-04-08
- Support for React 15.0 to react_on_rails. See #379 by brucek.
- Support for Node.js server side rendering. See #380 by alleycat and doc
- Generator removals to simplify installer. See #364 by jbhatab.
- Removed options for heroku, boostrap, and the linters from generator.
- Removed install for the Webpack Dev Server, as we can now do hot reloading with Rails, so the complexity of this feature is not justified. Nevertheless, the setup of React on Rails still supports this setup, just not with the generator.
- Documentation added for removed installer options.
5.1.1 - 2016-04-04
- Security Fixes: Address failure to sanitize console messages when server rendering and displaying in the browser console. See #366 and #370 by justin808
- railsContext includes the port number and a boolean if the code is being run on the server or client.
5.1.0 - 2016-04-03
All 5.1.0 changes can be found in #362 by justin808.
- Generator enhancements
- Generator adds line to spec/rails_helper.rb so that running specs will ensure assets are compiled.
- Other small changes to the generator including adding necessary npm scripts to allow React on Rails to build assets.
- Npm modules updated for generator.
- Added babel-runtime in to the client/package.json created.
- Server rendering
- Added more diagnostics for server rendering.
- Calls to setTimeout and setInterval are not logged for server rendering unless env TRACE_REACT_ON_RAILS is set to YES.
- Updated all project npm dependencies to latest.
- Update to node 5.10.0 for CI.
- Added babel-runtime as a peer dependency for the npm module.
5.0.0 - 2016-04-01
- Added
railsContext
, an object which gets passed always as the second parameter to both react component and redux store generator functions, both for server and client rendering. This provides data like the current locale, the pathname, etc. The data values are customizable by a new configuration calledrendering_extension
where you can create a module with a method calledrendering_extension
. This allows you to add additional values to the Rails Context. Implement one static method calledcustom_context(view_context)
and return a Hash. See #345 by justin808
- Previously, you could pass arbitrary additional html attributes to react_component. Now, you need to pass them in as a named parameter
html_options
to react_component.
- You must provide named attributes, including
props
for view helperreact_component
. See this commit for an example migration used for www.reactrails.com.
4.0.3 - 2016-03-17
ReactOnRailsHelper#react_component
: Invalid deprecation message when called with only one paramter, the component name.
4.0.2 - 2016-03-17
ReactOnRails::Controller#redux_store
: 2nd parameter changed to a named parameterprops
for consistency.
4.0.1 - 2016-03-16
- Switched to
heroku buildpacks:set
syntax rather than using a.buildpacks
file, which is deprecated. See #319 by esauter5. Includes both generator and doc updates.
4.0.0 - 2016-03-14
- spec/dummy is a full sample app of React on Rails techniques including the hot reloading of assets from Rails!
- Added helpers
env_stylesheet_link_tag
andenv_javascript_include_tag
to support hot reloading Rails. See the README.md for more details and see the example application inspec/dummy
. Also see how this is used in the tutorial: application.html.erb - Added optional parameter for ReactOnRails.getStore(name, throwIfMissing = true) so that you can check if a store is defined easily.
- Added controller
module ReactOnRails::Controller
. Adds methodredux_store
to setup redux stores in the view. - Added option
defer: true
for view helperredux_store
. This allows the view helper to specify the props for store hydration, yet still render the props at the bottom of the view. - Added view helper
redux_store_hydration_data
to render the props on the application's layout, near the bottom. This allows for the client hydration data to be parsed after the server rendering, which may result in a faster load time. - The checker for outdated bundles before running tests will two configuration options:
generated_assets_dir
andwebpack_generated_files
. - Better support for Turbolinks 5!
- Fixed generator check of uncommitted code for foreign languages. See #303 by nmatyukov.
- Added several parameters used for ensuring webpack assets are built for running tests:
config.generated_assets_dir
: Directory where your generated webpack assets go. You can have only one directory for this.config.webpack_generated_files
: List of files that will get created in thegenerated_assets_dir
. The test runner helper will ensure these generated files are newer than any of the files in the client directory.
- Generator default for webpack generated assets is now
app/assets/webpack
as we use this for both JavaScript and CSS generated assets.
- The test runner "assets up to date checker" is greatly improved.
- Lots of doc updates!
- Improved the spec/dummy sample app so that it supports CSS modules, hot reloading, etc, and it can server as a template for a new ReactOnRails installation.
- Deprecated calling
redux_store(store_name, props)
. The API has changed. Useredux_store(store_name, props: props, defer: false)
A new option calleddefer
allows the rendering of store hydration at the bottom of the your layout. Placeredux_store_hydration_data
on your layout. config.server_bundle_js_file
has changed. The default value is now blank, meaning no server rendering. Addtionally, if you specify the file name, you should not include the path, as that should be specified in theconfig.generated_assets_dir
.config.generated_assets_dirs
has been renamed toconfig.generated_assets_dir
(singular) and it only takes one directory.
3.0.6 - 2016-03-01
3.0.5 - 2016-02-26
3.0.4 - 2016-02-25
- Updated CHANGELOG.md to include contributors for each PR.
- Fixed config.server_bundle_js file value in generator to match generator setting of server rendering. See #295 by aaronvb.
3.0.3 - 2016-02-21
- Cleaned up code in
spec/dummy
to latest React and Redux APIs. See #282. - Update generator messages with helpful information. See #279.
- Other small generated comment fixes and doc fixes.
3.0.2 - 2016-02-15
- Fixed missing information in the helpful message after running the base install generator regarding how to run the node server with hot reloading support.
3.0.1 - 2016-02-15
- Fixed several jscs linter issues.
3.0.0 - 2016-02-15
- Fix Bootstrap Sass Append to Gemfile, missing new line. #262.
- Added helper
redux_store
and associated JavaScript APIs that allow multiple React components to use the same store. Thus, you initialize the store, with props, separately from the components. - Added forman to gemspec in case new dev does not have it globally installed. #248.
- Support for Turbolinks 5! #270.
- Added better error messages for
ReactOnRails.register()
. #273.
-
Calls to
react_component
should use a named argument of props. For example, change this:<%= react_component("ReduxSharedStoreApp", {}, prerender: false, trace: true) %>
to
<%= react_component("ReduxSharedStoreApp", props: {}, prerender: false, trace: true) %>
You'll get a deprecation message to change this.
-
Renamed
ReactOnRails.configure_rspec_to_compile_assets
toReactOnRails::TestHelper.configure_rspec_to_compile_assets
. The code has also been optimized to check for whether or not the compiled webpack bundles are up to date or not and will not run if not necessary. If you are using non-standard directories for your generated webpack assets (app/assets/javascripts/generated
andapp/assets/stylesheets/generated
) or have additional directories you wish the helper to check, you need to update your ReactOnRails configuration accordingly. See documentation for how to do this. #253. -
You have to call
ReactOnRails.register
to register react components. This was deprecated in v2. #273.
- See these changes of spec/dummy/spec/rails_helper.rb for an example. Add this line to your
rails_helper.rb
:
RSpec.configure do |config|
# Ensure that if we are running js tests, we are using latest webpack assets
ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
- Change view helper calls to react_component to use the named param of
props
. See forum post Using Regexp to update to ReactOnRails v3.
2.3.0 - 2016-02-01
- Added polyfills for
setInterval
andsetTimeout
in case other libraries expect these to exist. - Added much improved debugging for errors in the server JavaScript webpack file.
- See #244 for these improvements.
2.2.0 - 2016-01-29
- New JavaScript API for debugging TurboLinks issues. Be sure to see turbolinks docs.
ReactOnRails.setOptions({ traceTurbolinks: true });
. Removed the filedebug_turbolinks
added in 2.1.1. See #243.
2.1.1 - 2016-01-28
- Fixed regression where apps that were not using Turbolinks would not render components on page load.
ReactOnRails.render
returns a virtualDomElement Reference to your React component's backing instance. See #234.debug_turbolinks
helper for debugging turbolinks issues. See turbolinks.- Enhanced regression testing for non-turbolinks apps. Runs all tests for dummy app with turbolinks both disabled and enabled.
2.1.0 - 2016-01-26
- Added EnsureAssetsCompiled feature so that you do not accidentally run tests without properly compiling the JavaScript bundles. Add a line to your
rails_helper.rb
file to check that the latest Webpack bundles have been generated prior to running tests that may depend on your client-side code. See docs for more detailed instructions. #222 - Added migration guide for migrating from React-Rails. #219
- Added React on Rails Doctrine to docs. Discusses the project's motivations, conventions, and principles. #220
- Added ability to skip
display:none
style in the generated content tag for a component. Some developers may want to disable inline styles for security reasons. See generated config initializer file for example on settingskip_display_none
. #218
- Changed message when running the dev (a.k.a. "express" server). #227
- Fixed handling of Turbolinks. Code was checking that Turbolinks was installed when it was not yet because some setups load Turbolinks after the bundles. The changes to the code will check if Turbolinks is installed after the page loaded event fires. Code was also added to allow easy debugging of Turbolinks, which should be useful when v5 of Turbolinks is released shortly. Details of how to configure Turbolinks with troubleshooting were added to
docs
directory. #221 - Fixed issue with already initialized constant warning appearing when starting a Rails server #226
- Fixed to make backwards compatible with Ruby v2.0 and updated all Ruby and Node dependencies.
- Added better messages after generator runs. #210
- Fixed bug with version matching between gem and npm package.
- Move JavaScript part of react_on_rails to npm package 'react-on-rails'.
- Converted JavaScript code to ES6! with tests!
- No global namespace pollution. ReactOnRails is the only global added.
- New API. Instead of placing React components on the global namespace, you instead call ReactOnRails.register, passing an object where keys are the names of your components:
import ReactOnRails from 'react-on-rails';
ReactOnRails.register({name: component});
Best done with Object destructing:
import ReactOnRails from 'react-on-rails';
ReactOnRails.register(
{
Component1,
Component2
}
);
Previously, you used
window.Component1 = Component1;
window.Component2 = Component2;
This would pollute the global namespace. See details in the README.md for more information.
- Your jade template for the WebpackDevServer setup should use the new API:
ReactOnRails.render(componentName, props, domNodeId);
such as:
ReactOnRails.render("HelloWorldApp", {name: "Stranger"}, 'app');
- All npm dependency libraries updated. Most notable is going to Babel 6.
- Dropped support for react 0.13.
- JS Linter uses ShakaCode JavaScript style: https://github.com/shakacode/style-guide-javascript
- Generators account these differences.
- Update the
react_on_rails
gem. - Remove
//= require react_on_rails
from any files such asapp/assets/javascripts/application.js
. This file comes from npm now. - Search you app for 'generator_function' and remove lines in layouts and rb files that contain it. Determination of a generator function is handled automatically.
- Find your files where you registered client and server globals, and use the new ReactOnRails.register syntax. Optionally rename the files
clientRegistration.jsx
andserverRegistration.jsx
rather thanGlobals
. - Update your index.jade to use the new API
ReactOnRails.render("MyApp", !{props}, 'app');
- Update your webpack files per the example commit. Remove globally exposing React and ReactDom, as well as their inclusion in the
entry
section. These are automatically included now. - Run
cd client && npm i --save react-on-rails
to get react-on-rails into yourclient/package.json
. - You should also update any other dependencies if possible to match up with the react-webpack-rails-tutorial. This includes updating to Babel 6.
- If you want to stick with Babel 5 for a bit, see Issue #238.
- Missing Lodash from generated package.json #175
- Rails 3.2 could not run generators #182
- Better placement of jquery_ujs dependency #171
- Add more detailed description when adding --help option to generator #161
- Lots of better docs.
- Support
--skip-bootstrap
or-b
option for generator. - Create examples tasks to test generated example apps.
- Fix non-server rendering configuration issues.
- Fix application.js incorrect overwritten issue.
- Fix Gemfile dependencies.
- Fix several generator issues.
- Removed templates/client folder.
1.1.1 - 2015-11-28
- Support for React Router.
- Error and redirect handling.
- Turbolinks support.
- Fix several generator-related issues.