Limenius / ReactRenderer

Client and Server-side React rendering from PHP
MIT License
237 stars 37 forks source link

Fix: add railsContext property serverRenderReactComponent #3

Closed teameh closed 7 years ago

teameh commented 7 years ago

When server rendering components I'm getting:

An exception has been thrown during the rendering of a template ("V8Js::compileString():76203: TypeError: Cannot read property 'replace' of undefined").

I'm not sure why we did not figure this out earlier, but apparently their internal API changed more than we thought in v5. https://github.com/shakacode/react_on_rails/pull/345/files#diff-741e57aaaefab9559b7892657ec8c75eL270

Instead of passing the location we should pass a railsContext now. This is just a quick fix, I think it would be better if we implement the same behaviour in php later (https://github.com/Limenius/ReactRenderer/issues/4)

teameh commented 7 years ago

I'm not sure why we did not figure this out earlier

Ah, because it will only break if 'trace' is set to true, which I only use for development, when I hardly ever use server side rendering.