react_on_rails: [Rails 3.2][v6.9.0] Parsing error when fetching ReactOnRails context from script tag
Hi,
I updated the gem to the version 6.9.0 so it can be compatible with the node module (6.9.0).
I’m using it with Rails 3.2.
Unexpectedly, I got this parsing error:
Uncaught SyntaxError: Unexpected token i in JSON at position 18
at JSON.parse (<anonymous>)
at parseRailsContext (app.js:23226)
at reactOnRailsPageLoaded (app.js:23235)
at HTMLDocument.<anonymous> (app.js:23289)
This is the output I have in the script tag generated by the helper prepend_render_rails_context:
<script id="js-react-on-rails-context" type="application/json">
{
inMailer: false,
i18nLocale: fr,
i18nDefaultLocale: fr,
href: http://localhost:3000/,
location: /,
scheme: http,
host: localhost,
port: 3000,
pathname: /,
search: null,
httpAcceptLanguage: fr,en;q=0.8,en-US;q=0.6,zh-CN;q=0.4,zh;q=0.2,tr;q=0.2,nl;q=0.2,it;q=0.2,de;q=0.2,es;q=0.2,
serverSide: false
}
</script>
The generated output doesn’t seem to be formatted as json so it cannot be parsed correctly by the javascript. Is there something that I should have done in my configuration?
Thank you very much for your help (and your great great project)!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 27 (18 by maintainers)
Apparently I forgot to update the gem.
Here’s how I fix this:
rm -rf client/node_modulesbundle update react_on_railsnpm install react-on-rails @ latest --savenpm install@robwise, @kulakowka: Maybe we should do a logger.error?
https://github.com/shakacode/react_on_rails/blob/master/lib/react_on_rails/version_checker.rb#L29
Should be a logger.warn: