-
-
Notifications
You must be signed in to change notification settings - Fork 631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
should force load react-components which send over turbo-stream #1614
should force load react-components which send over turbo-stream #1614
Conversation
Important Auto Review SkippedAuto reviews are disabled on base/target branches other than the default branch. Please add the base/target branch pattern to the list of additional branches to be reviewed in the settings. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe recent updates focus on enhancing the React on Rails integration by introducing a Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
context.roots = []; | ||
} | ||
|
||
const el = document.querySelector(`[data-dom-id=${domId}]`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure domId
is sanitized to prevent potential XSS vulnerabilities.
- const el = document.querySelector(`[data-dom-id=${domId}]`);
+ const el = document.querySelector(`[data-dom-id='${CSS.escape(domId)}']`);
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const el = document.querySelector(`[data-dom-id=${domId}]`); | |
const el = document.querySelector(`[data-dom-id='${CSS.escape(domId)}']`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Judahmeek please review carefully
@@ -0,0 +1,3 @@ | |||
<%= turbo_frame_tag 'hello-turbo-stream' do %> | |||
<%= button_to "send me hello-turbo-stream component", turbo_stream_send_hello_world_path %> | |||
<% end %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi, i don't get it! what should i 'return' here. some document like other pages, right ?
@theforestvn88 Thanks! @Judahmeek and I will review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this seems like a solid piece of work.
Please make the requested changes while I look into resolving the CI failures related to Bundler version mismatch (in other words, the CI failures not related to your PR)
@@ -0,0 +1,3 @@ | |||
<%= turbo_stream.update 'hello-turbo-stream' do %> | |||
<%= react_component("HelloTurboStream", props: @app_props_hello_from_turbo_stream, force_load: true) %> | |||
<% end %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add return
spec/dummy/Gemfile
Outdated
@@ -5,3 +5,5 @@ source "https://rubygems.org" | |||
eval_gemfile File.expand_path("../../Gemfile.development_dependencies", __dir__) | |||
|
|||
gem "react_on_rails", path: "../.." | |||
|
|||
gem "turbo-rails" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add this gem to the Gemfile.development_dependencies file instead of here.
@theforestvn88 please rebase your PR on shakacode:judahmeek/bundler-version |
@theforestvn88 that PR is merged. Rebase on master please! |
@Judahmeek that wasn't good advice as the branch got deleted. |
@Judahmeek @theforestvn88 I recreated the branch so I could reopen this PR. Can I see an example of this fix used in https://github.com/shakacode/react-webpack-rails-tutorial? @theforestvn88 can you make a PR against that repo? |
* swap functions so the right errors show up
3441a27
to
8dce819
Compare
8dce819
to
4f44915
Compare
Looks like #1620 takes over. |
Summary
Support React On Rails w/Hotwire and Turbo Streams #1493, #1508
All turbo events (
turbo:before-render
,turbo:render
,.. ) will not dispatch withTurboStream
, except turbo:before-stream-render.And it looks like
turbo-rails
did not support aafter-stream-render
event, i don't know why yet.But
hotwired
send html,react_on_rails
sendscript
, right ?So my solution: send a script that will trigger load react component along with it.
render option
:force_load
which if true then the trigger load script will be concat with the component itself.reactOnRailsPageLoaded
which will query and reload all current react-components (not effective), i introduce new methodreactOnRailsComponentLoaded(react-component-dom-id)
to load directly the react-component that the script be sent along with.Pull Request checklist
Other Information
This change is
Summary by CodeRabbit
New Features
Enhancements
Documentation
Bug Fixes
Refactor
Tests