react-rails 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f3c2b4f28629f4fa197ec51a3951aa90ca430a4688f0f45d8eceac3a91c7309
4
- data.tar.gz: 43f8580d6678c51cc0f6a7037dda28f63e256073ed7c5d16867c87d31d15af35
3
+ metadata.gz: e21548e44de86710093640f1ec4b9fb7894a240d7f908cabcc9a6a0c271826dc
4
+ data.tar.gz: 5879119b9a1c41c818896a82fc6b3596119e46b286eab96a54ad8489c803db5f
5
5
  SHA512:
6
- metadata.gz: b2a3fdff4d9d1438d9935b1d63b9fa1e891d6a79cce5dfd10731c364681b4d1cfc0c017960184c15d91c1228b5efb18fbe5e600f509ad0385f9d3c667894ac15
7
- data.tar.gz: 84500c2291940cfeb41617f340ce59ee7e9de4f2a337b5b313dc42581fa5157b7ecaac759d00d5240b80cb48154e57eb590bce5183e951b01691deb3d9bd9898
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
- ## Supporters
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] = props_to_json(
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
 
@@ -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
@@ -4,6 +4,6 @@ module React
4
4
  module Rails
5
5
  # If you change this, make sure to update VERSIONS.md
6
6
  # and republish the UJS by updating package.json and `bundle exec rake ujs:publish`
7
- VERSION = "3.1.0"
7
+ VERSION = "3.1.1"
8
8
  end
9
9
  end
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.0
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-15 00:00:00.000000000 Z
14
+ date: 2023-08-16 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: appraisal