# Change Log 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 next version. NOTE: major versions of the npm module and the gem must be kept in sync. Migration instructions for the major updates can be found [here](docs/basics/upgrading-react-on-rails.md#upgrading-to-version-9.md). Some smaller migration information can be found here. ## Need Help Migrating? If you would like help in migrating between React on Rails versions or help with implementing server rendering, please contact [justin@shakacode.com](mailto:justin@shakacode.com) for information about our [React on Rails Pro Support Options](https://www.shakacode.com/react-on-rails-pro). We specialize in helping companies to quickly and efficiently move from versions before 9 to current. The older versions use the Rails asset pipeline to package client assets. The current and recommended way is to use Webpack 4 for asset preparation. You may also need help migrating from the `rails/webpacker`'s Webpack configuration to a better setup ready for Server Side Rendering. ## Contributors Please follow the recommendations outlined at [keepachangelog.com](http://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. ## Versions ### [Unreleased] Changes since last non-beta release. *Please add entries here for your pull requests that are not yet released.* ### [12.1.0] - 2021-03-23 #### Added - Added the ability to assign a module with a `call` method to `config.build_production_command`. See [the configuration docs](./docs/basics/configuration.md). [PR 1362: Accept custom module for config.build_production_command](https://github.com/shakacode/react_on_rails/pull/1362). #### Fixed - Stop setting NODE_ENV value during precompile, as it interferred with rails/webpacker's setting of NODE_ENV to production by default. Fixes [#1334](https://github.com/shakacode/react_on_rails/issues/1334). [PR 1356: Don't set NODE_ENV in assets.rake](https://github.com/shakacode/react_on_rails/pull/1356) by [alexrozanski](https://github.com/alexrozanski). ### [12.0.4] - 2020-11-14 #### Fixed - Install generator now specifies the version. Fixes [React on Rails Generator installs the older npm package #1336](https://github.com/shakacode/react_on_rails/issues/1336). [PR 1338Fix Generator to use Exact NPM Version](https://github.com/shakacode/react_on_rails/pull/1338) by [justin808](https://github.com/justin808). ### [12.0.3] - 2020-09-20 #### Fixed - 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](https://loadable-components.com/docs/server-side-rendering/#4-add-loadableready-client-side). [PR 1327](https://github.com/shakacode/react_on_rails/pull/1327) by [justin808](https://github.com/justin808). Loadable-Components is supported by [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro). ### [12.0.2] - 2020-07-09 #### Fixed - Remove dependency upon Redux for Typescript types. [PR 1323](https://github.com/shakacode/react_on_rails/pull/1306) by [justin808](https://github.com/justin808). ### [12.0.1] - 2020-07-09 #### Fixed - 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](https://github.com/shakacode/react_on_rails/pull/1306) by By [justin808](https://github.com/justin808). ### [12.0.0] - 2020-07-08 For upgrade instructions, see [docs/basics/upgrading-react-on-rails.md](./docs/basics/upgrading-react-on-rails.md). #### Major Improvements 1. **React Hooks Support** for top level components 2. **Typescript bindings** 3. **rails/webpacker** "just works" with React on Rails by default. 4. i18n support for generating a JSON file rather than a JS file. #### BREAKING CHANGE 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](https://github.com/shakacode/react_on_rails/pull/1268) by [justin808](https://github.com/justin808) See [docs/basics/upgrading-react-on-rails](./docs/basics/upgrading-react-on-rails.md#upgrading-to-v12) for details. #### Other Updates * `react_on_rails` fully supports `rails/webpacker`. The example test app in `spec/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 default `false` because 1. Production applications would typically have a server bundle that differs from the client bundle 2. 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](https://github.com/shakacode/react_on_rails/pull/1240). * Added support to export locales in JSON format. New option added `i18n_output_format` which allows to specify locales format either `JSON` or `JS`. **`JSON` format is now the default.** **Use this config setting to get the old behavior: config.i18n_output_format = 'js'** [PR 1271](https://github.com/shakacode/react_on_rails/pull/1271) by [ashgaliyev](https://github.com/ashgaliyev). - Added Typescript definitions to the Node package. By [justin808](https://github.com/justin808) and [judahmeek](https://github.com/judahmeek) in [PR 1287](https://github.com/shakacode/react_on_rails/pull/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](https://github.com/shakacode/react_on_rails/pull/1240). ### [11.3.0] - 2019-05-24 #### Added - Added method for retrieving any option from `render_options` [PR 1213](https://github.com/shakacode/react_on_rails/pull/1213) by [ashgaliyev](https://github.com/ashgaliyev). - html_options has an option for 'tag' to set the html tag name like this: `html_options: { tag: "span" }`. [PR 1208](https://github.com/shakacode/react_on_rails/pull/1208) by [tahsin352](https://github.com/tahsin352). ### [11.2.2] - 2018-12-24 #### Improved - 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 ## MIGRATION for v11.2 - If using **React on Rails Pro**, upgrade react_on_rails_pro to a version >= 1.3. #### Improved - 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](https://github.com/shakacode/react_on_rails/pull/1159) by [justin808](https://github.com/justin808) and [coopersamuel](https://github.com/coopersamuel). - Enabled the use of webpack-dev-server with Server-side rendering. [PR 1173](https://github.com/shakacode/react_on_rails/pull/1173) by [justin808](https://github.com/justin808) and [judahmeek](https://github.com/judahmeek). #### Changed - Changed the default for: ```rb config.raise_on_prerender_error = Rails.env.development? ``` Thus, developers will need to fix server rendering errors before continuing. [PR 1145](https://github.com/shakacode/react_on_rails/pull/1145) by [justin808](https://github.com/justin808). ### 11.2.0 - 2018-12-06 Do not use. Unpublished. Caused by an issue with the release script. ### [11.1.8] - 2018-10-14 #### Improved - Improved tutorial and support for HMR when using `rails/webpacker` for Webpack configuration. [PR 1156](https://github.com/shakacode/react_on_rails/pull/1156) by [justin808](https://github.com/justin808). ### [11.1.7] - 2018-10-10 #### Fixed - Fixed bug where intl parsing would fail when trying to parse integers or blank entries. by [sepehr500](https://github.com/sepehr500) ### [11.1.6] - 2018-10-05 #### Fixed - Fix client startup invoking render prematurely, **AGAIN**. Fix additional cases of client startup failing during interactive readyState". Closes [issue #1150](https://github.com/shakacode/react_on_rails/issues/1150). [PR 1152](https://github.com/shakacode/react_on_rails/pull/1152) by [rakelley](https://github.com/rakelley). ### [11.1.5] - 2018-10-03 #### Fixed - Fix client startup invoking render prematurely. Closes [issue #1150](https://github.com/shakacode/react_on_rails/issues/1150). [PR 1151](https://github.com/shakacode/react_on_rails/pull/1151) by [rakelley](https://github.com/rakelley). ### [11.1.4] - 2018-09-12 #### Fixed - Ignore Arrays in Rails i18n yml files. [PR 1129](https://github.com/shakacode/react_on_rails/pull/1129) by [vcarel](https://github.com/vcarel). - Fix to apply transform-runtime. And work with Babel 6 and 7. (Include revert of [PR 1136](https://github.com/shakacode/react_on_rails/pull/1136)) [PR 1140](https://github.com/shakacode/react_on_rails/pull/1140) by [Ryunosuke Sato](https://github.com/tricknotes). - Upgrade Babel version to 7 [PR 1141](https://github.com/shakacode/react_on_rails/pull/1141) by [Ryunosuke Sato](https://github.com/tricknotes). ### [11.1.3] - 2018-08-26 #### Fixed - Don't apply babel-plugin-transform-runtime inside react-on-rails to work with babel 7. [PR 1136](https://github.com/shakacode/react_on_rails/pull/1136) by [Ryunosuke Sato](https://github.com/tricknotes). - Add support for webpacker 4 prereleases. [PR 1134](https://github.com/shakacode/react_on_rails/pull/1134) by [Judahmeek](https://github.com/Judahmeek)) ### [11.1.2] - 2018-08-18 #### Fixed - 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](https://github.com/shakacode/react_on_rails/pull/1133) by [justin808](https://github.com/justin808) ### [11.1.1] - 2018-08-09 #### Fixed - `TRUE` was deprecated in ruby 2.4, using `true` instead. [PR 1128](https://github.com/shakacode/react_on_rails/pull/1128) by [Aguardientico](https://github.com/Aguardientico). ### [11.1.0] - 2018-08-07 #### Added - 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](https://github.com/shakacode/react_on_rails/pull/1121) by [justin808](https://github.com/justin808) * Added configuration option random_dom_id * Added method RenderOptions has_random_dom_id? #### Fixed - Fix invalid warn directive. [PR 1123](https://github.com/shakacode/react_on_rails/pull/1123) by [mustangostang](https://github.com/mustangostang). ### [11.0.10] - 2018-07-22 #### Fixed - 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](https://github.com/shakacode/react_on_rails/pull/1117) and [PR 1118](https://github.com/shakacode/react_on_rails/pull/1118) by [justin808](https://github.com/justin808). - Properly clearing hydrated stores when server rendering. [PR 1120](https://github.com/shakacode/react_on_rails/pull/1120) by [squadette](https://github.com/squadette). ### [11.0.9] - 2018-06-24 - Handle