Closed tmlayton closed 8 years ago
I think the following should happen:
Turbolinks.replaceNode(...)
as the public API, so a monkey patch of the DOM isn't needed here https://github.com/ssorallen/turbo-react/blob/e0048b78d2c915d0517efff1afdf9c6cf7b6ca75/src/reactize.js#L54Turbolinks.replaceNode(...)
peerDependencies
at best. (#18)replaceNode
. It needs some more investigation.data-react-id
attributes. Diff'ing
doesn't work after that because the existence of those attrs makes React
treat the DOM as a pre-rendered document. Unsure if there are enough hooks
to circumvent that?TurboReact currently includes Turbolinks, but I don't think it should
agreed 100% :) also, it'd be very nice if it were available as a rails engine
@qq99, I'm familiar with Rails but not with writing Rails engines. I can check that out too.
https://github.com/ssorallen/turbo-react/blob/e0048b78d2c915d0517efff1afdf9c6cf7b6ca75/src/reactize.js#L24-L30 should be changed to call the original Turbolinks.replaceNode(...)
I took that suggestion and implemented it in commit https://github.com/ssorallen/turbo-react/commit/2ffd0311ee6c0b1f3fc3be50f8a5914e41fe562f.
What would making TurboReact a Rails engine solve? Happy to take a stab at it but I don't understand the benefit.
It let's you install it more like:
gem 'turboreact'
into your Gemfile#= require turboreact
in your application.js manifestIt seems a bit strange to have to use npm to install something in a RoR project
:+1: @qq99, if you are familiar with Rails Engines a "turboreact-rails" Gem would be great. I agree using NPM in a Rails project feels awkward.
So is this suitable for production? The only thing that threw me off was the caching of react ids. Seems like it could break stuff.
@jbhatab TurboReact currently disables the Turbolinks cache because of the problem of caching React IDs.
The library doesn't have automated testing yet, but if it runs into any problems it falls back to letting Turbolinks work like normal. If you are comfortable with document.replaceChild
being monkeypatched, feel free to try it out.
@ssorallen continuation from rails/turbolinks#491