react-rails 3.1.0 → 3.1.1
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/README.md +2 -24
- data/lib/react/rails/component_mount.rb +1 -15
- data/lib/react/rails/railtie.rb +0 -1
- 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: e21548e44de86710093640f1ec4b9fb7894a240d7f908cabcc9a6a0c271826dc
|
4
|
+
data.tar.gz: 5879119b9a1c41c818896a82fc6b3596119e46b286eab96a54ad8489c803db5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd4903039cd95c518f5b6cb9e5021711693cd0cca1a251d00957e5b03df88d87e5c2c57e1f1f6fbc24bf1d9553d8d23523c1f33caaa218e2953e5124e27874a5
|
7
|
+
data.tar.gz: 830bf9d620edcc4084e88f330aa30a7f091cb56eed48d17bd7ca302878c912fa3ccead712bde0ba27369dad9d4e3768d5f28b564ac596672b8ec98bdbc2f2002
|
data/README.md
CHANGED
@@ -68,8 +68,6 @@ 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)
|
73
71
|
- [Common Errors](#common-errors)
|
74
72
|
- [Getting warning for `Can't resolve 'react-dom/client'` in React < 18](#getting-warning-for-cant-resolve-react-domclient-in-react--18)
|
75
73
|
- [Undefined Set](#undefined-set)
|
@@ -77,7 +75,6 @@ Read the [full review here](https://clutch.co/profile/shakacode#reviews?sort_by=
|
|
77
75
|
- [HMR](#hmr)
|
78
76
|
- [Related Projects](#related-projects)
|
79
77
|
- [Contributing](#contributing)
|
80
|
-
- [Supporters](#supporters)
|
81
78
|
|
82
79
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
83
80
|
|
@@ -531,6 +528,7 @@ use it like so:
|
|
531
528
|
ReactUJS.getConstructor = ReactUJS.constructorFromRequireContext(require.context('components', true));
|
532
529
|
```
|
533
530
|
|
531
|
+
|
534
532
|
## Server-Side Rendering
|
535
533
|
|
536
534
|
You can render React components inside your Rails server with `prerender: true`:
|
@@ -803,26 +801,6 @@ For the vast majority of cases this will get you most of the migration:
|
|
803
801
|
- add `import PropTypes from 'prop-types'` (Webpacker only)
|
804
802
|
- re-run `bundle exec rails webpacker:install:react` to update npm packages (Webpacker only)
|
805
803
|
|
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
|
-
|
826
804
|
## Common Errors
|
827
805
|
### Getting warning for `Can't resolve 'react-dom/client'` in React < 18
|
828
806
|
|
@@ -879,7 +857,7 @@ By contributing to React-Rails, you agree to abide by the [code of conduct](http
|
|
879
857
|
|
880
858
|
You can always help by submitting patches or triaging issues. Even offering reproduction steps to issues is incredibly helpful!
|
881
859
|
|
882
|
-
|
860
|
+
# Supporters
|
883
861
|
|
884
862
|
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!
|
885
863
|
|
@@ -56,10 +56,7 @@ 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] =
|
60
|
-
props,
|
61
|
-
null_to_undefined: Dummy::Application.config.react.null_to_undefined_props
|
62
|
-
)
|
59
|
+
data[:react_props] = (props.is_a?(String) ? props : props.to_json)
|
63
60
|
data[:hydrate] = "t" if prerender_options
|
64
61
|
|
65
62
|
num_components = @cache_ids.count { |c| c.start_with? name }
|
@@ -70,17 +67,6 @@ module React
|
|
70
67
|
html_options
|
71
68
|
end
|
72
69
|
|
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
|
-
|
84
70
|
def rendered_tag(html_options, &block)
|
85
71
|
html_tag = html_options[:tag] || :div
|
86
72
|
|
data/lib/react/rails/railtie.rb
CHANGED
@@ -12,7 +12,6 @@ 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
|
16
15
|
|
17
16
|
# Server rendering:
|
18
17
|
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.1.
|
4
|
+
version: 3.1.1
|
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-16 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: appraisal
|