Fix reactOnRailsPageUnloaded when there is no component on the page#1498
Fix reactOnRailsPageUnloaded when there is no component on the page#1498justin808 merged 2 commits intoshakacode:masterfrom
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.
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.rootsis not initialized. This causefindContext().rootsinreactOnRailsPageUnloadedto be undefined, andfor .. ofthrows 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