-
-
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
Fix reactOnRailsPageUnloaded when there is no component on the page #1498
Conversation
Nice, I actually hit this while I was trying |
@NhanHo can you please add a CHANGELOG entry? I'll merge as soon as this passes CI. |
// If no react on rails components | ||
if (!roots) return; | ||
|
||
for (const root of roots) { |
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.
Looks OK for me. @alexeyr-ci1 @alexeyr please review as you added the prior line for React 18.
This seems harmless, so I'll merge. Still, I'd like a post-merge review.
ef684f9
to
70dac07
Compare
@justin808 I fixed the linter issue and added changelog. If you decide to merge the other PR, you can close this one. Thanks a lot for your work on Shakapacker and related projects. |
@NhanHo Please merge https://github.com/shakacode/react_on_rails/pull/1499/files into your branch and I'll merge. |
f24aa88
to
c6b4092
Compare
@justin808 Updated |
Thanks @NhanHo! |
In
reactOnRailsPageLoaded
, if we finds no react component, the function return andcontext.roots
is not initialized. This causefindContext().roots
inreactOnRailsPageUnloaded
to be undefined, andfor .. of
throws an exception.This should mostly affect app using both hotwire and react_on_rails, as the recommended way to load js is to do the same file everywhere, otherwise the issue can be avoided by just not loading react_on_rails
This change is