-
-
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
Turbo forms with react_component not rendering React #1508
Comments
@uvera can we get a small reproducible repo? @tomdracz any opinions of this? |
Here it is Please check out and when running server React component does not get rendered after form submission and turbo rerender. |
See #1620 |
So I'm using turbo streams for re-rendering forms when there are errors.
where I replace the form
edit.turbo_stream.erb
where form
_form.html.erb
where controller actions
The issue arises when I submit the form, react_component does not get re-rendered/hydrated even with
The workaround I found is event listening for "turbo:before-stream-render"
turboReloadJs
is just for re-initializing flowbite/tailwindcssthis selector
[data-signal-react-rerender]
is searching for span tag fromsignal_react_rerender
Another thing
Something I noticed is without debounced and delayed call to
ReactOnRails.reactOnRailsPageLoaded();
console warns with
Warning: You are calling ReactDOMClient.createRoot() on a container that has already been passed to createRoot() before. Instead, call root.render() on the existing root instead if you want to update it.
This is caused because this event gets called twice and of course, it's happening before stream rendering.
Environment
Expected behavior
ReactOnRails should re-render/hydrate components after turbo-stream form replacement where we have
react_component
helper called within the replaced formActual behavior
Components do not get re-rendered/hydrated after turbo-stream form replacement
Small, reproducible repo
https://github.com/uvera/React-on-rails-turbo-js-bug-reproduction
The text was updated successfully, but these errors were encountered: