fix(prerender) accept string props#268
fix(prerender) accept string props#268rmosolgo merged 2 commits intoreactjs:masterfrom rmosolgo:prerender-string-props-fix
Conversation
|
I tried this out and I'm running into an issue with sprockets now. In particular being thrown from This is kind of confusing because it is a call to //= require react that is raising the exception |
|
wow, is there any more stack trace to that? If it's booting a renderer and trying to prerender, I guess it's coming from here: https://github.com/reactjs/react-rails/blob/master/lib/react/server_rendering/sprockets_renderer.rb#L11 But why would it work fine in the asset pipeline but not in prerender? |
|
Reproduced on Sprockets 2.8 & 2.12. Oh, I misunderstood: it's coming from the asset pipeline, not from prerender! |
|
Correct, this is for the client side JS file loaded in the rails layout. |
|
Looks like this was touched recently in I didn't notice it before because I was on sprockets 3 :S |
|
@mchristen sounds like a sprockets-rails 2.3.1 issue, see this comment: rails/sprockets-rails#247 (comment) |
|
It definitely occurs prior to that version as well(at least as early as 2.2.4). When I first ran into the error I came across that issue on sprocket-rails and saw that code was touched with 2.3.1 so I updated to that version to see if the problem went away. When the problem persisted is when I made the comment above. Either way it looks like there will be a fix shortly, thanks for the work! |
|
aiiiyayay well the regression test for this particular issue passes, so i'm gonna go for it |
fix(prerender) accept string props
|
@mchristen they've shipped Please let me know if you can confirm/deny, if we're clear with the latest sprockets-rails I want to get ready for a new version release :D |
My first API was shoving
prerender:into the props hash, but obviously that doesn't work if props isn't a hash!So instead, pass
prerender_optionsalong through the ServerRendering pipeline. In theory, a render could take any options.SprocketsRendererlooks for:static, to useReact.renderToStaticMarkup