react-rails 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -4
- data/README.md +25 -3
- data/lib/react/rails/component_mount.rb +15 -1
- data/lib/react/rails/railtie.rb +1 -0
- data/lib/react/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1f3c2b4f28629f4fa197ec51a3951aa90ca430a4688f0f45d8eceac3a91c7309
|
|
4
|
+
data.tar.gz: 43f8580d6678c51cc0f6a7037dda28f63e256073ed7c5d16867c87d31d15af35
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b2a3fdff4d9d1438d9935b1d63b9fa1e891d6a79cce5dfd10731c364681b4d1cfc0c017960184c15d91c1228b5efb18fbe5e600f509ad0385f9d3c667894ac15
|
|
7
|
+
data.tar.gz: 84500c2291940cfeb41617f340ce59ee7e9de4f2a337b5b313dc42581fa5157b7ecaac759d00d5240b80cb48154e57eb590bce5183e951b01691deb3d9bd9898
|
data/CHANGELOG.md
CHANGED
|
@@ -5,10 +5,17 @@ If you need help upgrading `react-rails`, `webpacker` to `shakapacker`, or JS pa
|
|
|
5
5
|
[#1209 2.7 Release Discussion](https://github.com/reactjs/react-rails/issues/1209)
|
|
6
6
|
|
|
7
7
|
## Unreleased
|
|
8
|
-
Changes since last non-beta release.
|
|
8
|
+
Changes since the last non-beta release.
|
|
9
9
|
|
|
10
10
|
_Please add entries here for your pull requests that are not yet released._
|
|
11
11
|
|
|
12
|
+
## [3.1.0] - 2023-08-15
|
|
13
|
+
|
|
14
|
+
#### Added
|
|
15
|
+
- Added option to replace `null`s in props with `undefined` via `config.react.null_to_undefined_props` in `config/application.rb` #1293
|
|
16
|
+
|
|
17
|
+
## [3.0.0] - 2023-08-14
|
|
18
|
+
|
|
12
19
|
### Breaking Changes
|
|
13
20
|
- Requires separate compilations for server & client bundles if using Shakapacker (see [Webpack config](https://github.com/reactjs/react-rails/tree/master/test/dummy/config/webpack)) #1274
|
|
14
21
|
- 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. #1274
|
|
@@ -555,6 +562,8 @@ _Please add entries here for your pull requests that are not yet released._
|
|
|
555
562
|
- Server rendering with `prerender: true`
|
|
556
563
|
- Transform `.jsx` in the asset pipeline
|
|
557
564
|
|
|
558
|
-
[Unreleased]: https://github.com/reactjs/react-rails/compare/
|
|
559
|
-
[
|
|
560
|
-
[
|
|
565
|
+
[Unreleased]: https://github.com/reactjs/react-rails/compare/v3.1.0...master
|
|
566
|
+
[3.1.0]: https://github.com/reactjs/react-rails/compare/v3.0.0...v3.1.0
|
|
567
|
+
[3.0.0]: https://github.com/reactjs/react-rails/compare/v2.7.1...v3.0.0
|
|
568
|
+
[2.7.1]: https://github.com/reactjs/react-rails/compare/v2.7.0...v2.7.1
|
|
569
|
+
[2.7.0]: https://github.com/reactjs/react-rails/compare/v2.6.2...v2.7.0
|
data/README.md
CHANGED
|
@@ -32,7 +32,7 @@ Here's a testimonial of how ShakaCode can help, from [Florian Gößler](https://
|
|
|
32
32
|
|
|
33
33
|
Read the [full review here](https://clutch.co/profile/shakacode#reviews?sort_by=date_DESC#review-2118154). Here's [another review of a Shakapacker migration that led to more work](https://clutch.co/profile/shakacode#reviews?sort_by=date_DESC#review-2096078).
|
|
34
34
|
|
|
35
|
-
##
|
|
35
|
+
## Resources
|
|
36
36
|
* [Click to join **React + Rails Slack**](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE). Then join the channel `#react-rails`.
|
|
37
37
|
* If you are upgrading, you might consider migrating to the [react_on_rails](https://github.com/shakacode/react_on_rails) gem.
|
|
38
38
|
* Source code example utilizing React-Rails: https://github.com/BookOfGreg/react-rails-example-app
|
|
@@ -68,6 +68,8 @@ Read the [full review here](https://clutch.co/profile/shakacode#reviews?sort_by=
|
|
|
68
68
|
- [Upgrading](#upgrading)
|
|
69
69
|
- [2.7 to 3.0](#27-to-30)
|
|
70
70
|
- [2.3 to 2.4](#23-to-24)
|
|
71
|
+
- [Other features](#other-features)
|
|
72
|
+
- [Replace `null` with `undefined` in props](#replace-null-with-undefined-in-props)
|
|
71
73
|
- [Common Errors](#common-errors)
|
|
72
74
|
- [Getting warning for `Can't resolve 'react-dom/client'` in React < 18](#getting-warning-for-cant-resolve-react-domclient-in-react--18)
|
|
73
75
|
- [Undefined Set](#undefined-set)
|
|
@@ -75,6 +77,7 @@ Read the [full review here](https://clutch.co/profile/shakacode#reviews?sort_by=
|
|
|
75
77
|
- [HMR](#hmr)
|
|
76
78
|
- [Related Projects](#related-projects)
|
|
77
79
|
- [Contributing](#contributing)
|
|
80
|
+
- [Supporters](#supporters)
|
|
78
81
|
|
|
79
82
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
80
83
|
|
|
@@ -528,7 +531,6 @@ use it like so:
|
|
|
528
531
|
ReactUJS.getConstructor = ReactUJS.constructorFromRequireContext(require.context('components', true));
|
|
529
532
|
```
|
|
530
533
|
|
|
531
|
-
|
|
532
534
|
## Server-Side Rendering
|
|
533
535
|
|
|
534
536
|
You can render React components inside your Rails server with `prerender: true`:
|
|
@@ -801,6 +803,26 @@ For the vast majority of cases this will get you most of the migration:
|
|
|
801
803
|
- add `import PropTypes from 'prop-types'` (Webpacker only)
|
|
802
804
|
- re-run `bundle exec rails webpacker:install:react` to update npm packages (Webpacker only)
|
|
803
805
|
|
|
806
|
+
## Other features
|
|
807
|
+
|
|
808
|
+
### Replace `null` with `undefined` in props
|
|
809
|
+
|
|
810
|
+
React-Rails converts `nil` to `null` while parsing props from Ruby to JavaScript. Optionally, you can configure React-Rails to parse `nil` values to `undefined` as per the following:
|
|
811
|
+
|
|
812
|
+
```ruby
|
|
813
|
+
# config/application.rb
|
|
814
|
+
module TheAppName
|
|
815
|
+
class Application < Rails::Application
|
|
816
|
+
# ...
|
|
817
|
+
# Set to true to convert null values in props into undefined
|
|
818
|
+
config.react.null_to_undefined_props = true
|
|
819
|
+
# ...
|
|
820
|
+
end
|
|
821
|
+
end
|
|
822
|
+
```
|
|
823
|
+
|
|
824
|
+
More information in: [discussion#1272](https://github.com/reactjs/react-rails/discussions/1272).
|
|
825
|
+
|
|
804
826
|
## Common Errors
|
|
805
827
|
### Getting warning for `Can't resolve 'react-dom/client'` in React < 18
|
|
806
828
|
|
|
@@ -857,7 +879,7 @@ By contributing to React-Rails, you agree to abide by the [code of conduct](http
|
|
|
857
879
|
|
|
858
880
|
You can always help by submitting patches or triaging issues. Even offering reproduction steps to issues is incredibly helpful!
|
|
859
881
|
|
|
860
|
-
|
|
882
|
+
## Supporters
|
|
861
883
|
|
|
862
884
|
The following companies support the development of this and other open-source projects maintained by ShakaCode by providing licenses to the ShakaCode team. ShakaCode stands by the usefulness of these products!
|
|
863
885
|
|
|
@@ -56,7 +56,10 @@ module React
|
|
|
56
56
|
unless prerender_options == :static
|
|
57
57
|
html_options[:data].tap do |data|
|
|
58
58
|
data[:react_class] = name
|
|
59
|
-
data[:react_props] = (
|
|
59
|
+
data[:react_props] = props_to_json(
|
|
60
|
+
props,
|
|
61
|
+
null_to_undefined: Dummy::Application.config.react.null_to_undefined_props
|
|
62
|
+
)
|
|
60
63
|
data[:hydrate] = "t" if prerender_options
|
|
61
64
|
|
|
62
65
|
num_components = @cache_ids.count { |c| c.start_with? name }
|
|
@@ -67,6 +70,17 @@ module React
|
|
|
67
70
|
html_options
|
|
68
71
|
end
|
|
69
72
|
|
|
73
|
+
def props_to_json(props, options = { null_to_undefined: false })
|
|
74
|
+
return props if props.is_a?(String)
|
|
75
|
+
return props.to_json unless options[:null_to_undefined]
|
|
76
|
+
|
|
77
|
+
# This regex matches key:value with null values while ensuing no string with similar
|
|
78
|
+
# pattern gets matched. It doesn't include null values in arrays.
|
|
79
|
+
props.to_json
|
|
80
|
+
.gsub(/([^\\]":)null([,}\]])/, '\1undefined\2') # match simple null values
|
|
81
|
+
.gsub(/([^\\]":(\[[^\\"]+,|\[))null([,\]])/, '\1undefined\3') # Match nulls in array
|
|
82
|
+
end
|
|
83
|
+
|
|
70
84
|
def rendered_tag(html_options, &block)
|
|
71
85
|
html_tag = html_options[:tag] || :div
|
|
72
86
|
|
data/lib/react/rails/railtie.rb
CHANGED
|
@@ -12,6 +12,7 @@ module React
|
|
|
12
12
|
config.react.jsx_transformer_class = nil # defaults to BabelTransformer
|
|
13
13
|
config.react.camelize_props = false # pass in an underscored hash but get a camelized hash
|
|
14
14
|
config.react.sprockets_strategy = nil # how to attach JSX to the asset pipeline (or `false` for none)
|
|
15
|
+
config.react.null_to_undefined_props = false # Set to true to convert null values in props into undefined
|
|
15
16
|
|
|
16
17
|
# Server rendering:
|
|
17
18
|
config.react.server_renderer_pool_size = 1 # increase if you're on JRuby
|
data/lib/react/rails/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: react-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Paul O’Shannessy
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2023-08-
|
|
14
|
+
date: 2023-08-15 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: appraisal
|