Closed margaretjoanmiller closed 8 years ago
The quirk is that fromJSON
requires a string, not the object.
There's an open issue with the main transit module asking about accepting an object instead.
See https://github.com/cognitect/transit-js/issues/23 for the upstream issue which would enable passing the array / object directly.
I'm trying to send my redux state preloaded for a universal react app (with the format:
) and I am sending this with
...window.__INITIAL_STATE__ = ${transit.toJSON(initialState)};...
(which is, as denoted by the``, part of a template string that is sent on every page request) to be reevaluated with
const store = configureStore(transit.fromJSON(window.__INITIAL_STATE__));. However, this produces the error
Uncaught SyntaxError: Unexpected token ~ in JSON at position 0` and the app, from what I can tell, does not actually load; it just displays what was prerendered. The JSON that is sent, according to chrome dev tools, is: