glenjamin / glenjamin/transit-immutable-js
Allow to pass object to fromJSON
- Dominant language
- JavaScript
- Stars
- 250
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Description
Use case scenario:
Server renders:
``` html
window.__PRELOADED_STATE__ = ${transit.toJSON(preloadedState)};
```
Client picks up `__PRELOADED_STATE__`, which is a valid JSON, therefore it is converted to an object. To use it, I need to cast it back to string, e.g.
``` js
console.log('window.__PRELOADED_STATE__', transit.fromJSON(JSON.stringify(window.__PRELOADED_STATE__)));
```
Alternatively, I can stringify the object twice on server: once using `transit-immutable-js` and
second time using `JSON.stringify`, e.g.
``` html
window.__PRELOADED_STATE__ = ${JSON.stringify(transit.toJSON(preloadedState))};
```
Preferably though,`transit-immutable-js` should be able to accept an object.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.