react-rails 3.0.0.rc.0 → 3.1.0

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: c8d2a4cb3734964b0395e076976f0f518467d0ece8559e6fe46c50db07dbbef0
4
- data.tar.gz: 5219597584239f5624dadd79049d295346017102bf2d28663ba533adc1c7481f
3
+ metadata.gz: 1f3c2b4f28629f4fa197ec51a3951aa90ca430a4688f0f45d8eceac3a91c7309
4
+ data.tar.gz: 43f8580d6678c51cc0f6a7037dda28f63e256073ed7c5d16867c87d31d15af35
5
5
  SHA512:
6
- metadata.gz: cfbb05294e9838ba2044a47c7171e115d8ad27252cc38488f44009ce7e1518bf1cd03138a18f40d6dfb52b2d05f5a2a08e45a891ef27a3eeb2ab539091ddf63f
7
- data.tar.gz: 42dadcb99c93a42584af25c9ab4dcfa09d30c236bec22a59f48be8d78079daf1c12711cbc5e75e7b1e2313ce1b39e3ddf556ea4bc65045d0f7a7bc4f3541c491
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/v2.7.1...master
559
- [2.7.1]: https://github.com/shakacode/shakapacker/compare/v2.7.0...v2.7.1
560
- [2.7.0]: https://github.com/shakacode/shakapacker/compare/v2.6.2...v2.7.0
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
- ## Resouces
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
 
@@ -855,6 +877,37 @@ With 5 Million+ downloads of the react-rails Gem and another 2 Million+ download
855
877
 
856
878
  By contributing to React-Rails, you agree to abide by the [code of conduct](https://github.com/reactjs/react-rails/blob/master/CODE_OF_CONDUCT.md).
857
879
 
858
- You can always help by submitting patches or triaging issues, even offering reproduction steps to issues is incredibly helpful!
880
+ You can always help by submitting patches or triaging issues. Even offering reproduction steps to issues is incredibly helpful!
881
+
882
+ ## Supporters
883
+
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!
885
+
886
+ <br />
887
+ <br />
888
+
889
+ <a href="https://www.jetbrains.com">
890
+ <img src="https://user-images.githubusercontent.com/4244251/184881139-42e4076b-024b-4b30-8c60-c3cd0e758c0a.png" alt="JetBrains" height="120px">
891
+ </a>
892
+ <a href="https://scoutapp.com">
893
+ <picture>
894
+ <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/4244251/184881147-0d077438-3978-40da-ace9-4f650d2efe2e.png">
895
+ <source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/4244251/184881152-9f2d8fba-88ac-4ba6-873b-22387f8711c5.png">
896
+ <img alt="ScoutAPM" src="https://user-images.githubusercontent.com/4244251/184881152-9f2d8fba-88ac-4ba6-873b-22387f8711c5.png" height="120px">
897
+ </picture>
898
+ </a>
899
+ <a href="https://controlplane.com">
900
+ <picture>
901
+ <img alt="Control Plane" src="https://github.com/shakacode/.github/assets/20628911/90babd87-62c4-4de3-baa4-3d78ef4bec25" height="120px">
902
+ </picture>
903
+ </a>
904
+ <br />
905
+ <a href="https://www.browserstack.com">
906
+ <picture>
907
+ <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/4244251/184881122-407dcc29-df78-4b20-a9ad-f597b56f6cdb.png">
908
+ <source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/4244251/184881129-e1edf4b7-3ae1-4ea8-9e6d-3595cf01609e.png">
909
+ <img alt="BrowserStack" src="https://user-images.githubusercontent.com/4244251/184881129-e1edf4b7-3ae1-4ea8-9e6d-3595cf01609e.png" height="55px">
910
+ </picture>
911
+ </a>
859
912
 
860
913
  Please see our [Contribution guide](https://github.com/reactjs/react-rails/blob/master/CONTRIBUTING.md) for more info.
@@ -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] = (props.is_a?(String) ? props : props.to_json)
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
 
@@ -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
@@ -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.0.0.rc.0"
7
+ VERSION = "3.1.0"
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.0.0.rc.0
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-07-31 00:00:00.000000000 Z
14
+ date: 2023-08-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: appraisal
@@ -351,9 +351,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
351
351
  version: '0'
352
352
  required_rubygems_version: !ruby/object:Gem::Requirement
353
353
  requirements:
354
- - - ">"
354
+ - - ">="
355
355
  - !ruby/object:Gem::Version
356
- version: 1.3.1
356
+ version: '0'
357
357
  requirements: []
358
358
  rubygems_version: 3.2.32
359
359
  signing_key: