{"action":"created","issue":{"url":"https://api.github.com/repos/kirill-konshin/next-redux-wrapper/issues/90","repository_url":"https://api.github.com/repos/kirill-konshin/next-redux-wrapper","labels_url":"https://api.github.com/repos/kirill-konshin/next-redux-wrapper/issues/90/labels{/name}","comments_url":"https://api.github.com/repos/kirill-konshin/next-redux-wrapper/issues/90/comments","events_url":"https://api.github.com/repos/kirill-konshin/next-redux-wrapper/issues/90/events","html_url":"https://github.com/kirill-konshin/next-redux-wrapper/issues/90","id":321007768,"node_id":"MDU6SXNzdWUzMjEwMDc3Njg=","number":90,"title":"Issue with Immutable.js","user":{"login":"jasonleibowitz","id":2746773,"node_id":"MDQ6VXNlcjI3NDY3NzM=","avatar_url":"https://avatars2.githubusercontent.com/u/2746773?v=4","gravatar_id":"","url":"https://api.github.com/users/jasonleibowitz","html_url":"https://github.com/jasonleibowitz","followers_url":"https://api.github.com/users/jasonleibowitz/followers","following_url":"https://api.github.com/users/jasonleibowitz/following{/other_user}","gists_url":"https://api.github.com/users/jasonleibowitz/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonleibowitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonleibowitz/subscriptions","organizations_url":"https://api.github.com/users/jasonleibowitz/orgs","repos_url":"https://api.github.com/users/jasonleibowitz/repos","events_url":"https://api.github.com/users/jasonleibowitz/events{/privacy}","received_events_url":"https://api.github.com/users/jasonleibowitz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-05-08T01:00:14Z","updated_at":"2018-06-05T06:18:26Z","closed_at":"2018-05-09T15:57:58Z","author_association":"NONE","body":"I'm trying to configure immutable.js with next-redux-wrapper@2.0.0-beta.4 - I followed your suggestion [in the docs](https://github.com/kirill-konshin/next-redux-wrapper#custom-serialization-and-deserialization), but I'm still having lots of issues. It seems that on the server the serialize function is run and state on the server is immutable. However, on the client deserialize is run and state is a POJO. (I'm also using [next-redux-saga](https://github.com/bmealhouse/next-redux-saga)). \r\n\r\nWhat I see happening is that on initial load the site is SSR and all the data appears correctly. However, after a few second the component re-renders client side and then I get an error that I cannot get values from the items via `.get`. \r\n\r\nI added some console.log statements and see `/// serialize state` 3 times on the server followed by `/// deserialize state` 3 times on the client. Once I see that log in the client, that's when the page errors out and the data in the component is no longer immutable. \r\n\r\nP.S. I tried using `fromJS` and `toJS` as the serialize and deserialize functions, but for some reason that didn't work. Using `json-immutable` from the readme seems to work, initially. \r\n\r\nI'll share some code snippets: \r\n\r\n#### store.js\r\n```\r\nexport function configureStore (initialState = {}) {\r\n  const store = createStore(\r\n    rootReducer,\r\n    initialState,\r\n    bindMiddleware([sagaMiddleware])\r\n  )\r\n\r\n  store.runSagaTask = () => {\r\n    store.sagaTask = sagaMiddleware.run(rootSaga)\r\n  };\r\n\r\n  // run the rootSaga initially\r\n  store.runSagaTask();\r\n  return store;\r\n}\r\n```\r\n\r\n#### _app.js\r\n```\r\nimport withRedux from 'next-redux-wrapper';\r\nimport nextReduxSaga from 'next-redux-saga';\r\nimport { configureStore } from 'store';\r\nconst { serialize, deserialize } = require('json-immutable');\r\n\r\n...\r\n\r\nexport default withRedux(configureStore, {\r\n  serializeState: state => {\r\n    console.log('/// serialize state');\r\n    return serialize(state);\r\n  },\r\n  deserializeState: state => {\r\n    console.log('/// deserialize state');\r\n    return deserialize(state)\r\n  }\r\n})(nextReduxSaga(MyApp));\r\n```\r\n\r\n#### pages/index.js\r\n```\r\nexport class Homepage extends React.Component {\r\n  static async getInitialProps({ store, isServer }) {\r\n    const today = moment().format('MM-DD');\r\n    const items = getItems(store.getState());\r\n\r\n    if (!items.size) {\r\n      store.dispatch(requestItems(today));\r\n    }\r\n\r\n    return { items };\r\n  }\r\n\r\n  render () {\r\n    const { items } = this.props;\r\n    items.map(t => {\r\n      console.log(Immutable.Iterable.isIterable(t));\r\n      return t;\r\n    })\r\n    return (\r\n      <h1>test</h1>\r\n    )\r\n  }\r\n}\r\n\r\nexport default connect(createStructuredSelector({\r\n  items: getItems,\r\n}))(Homepage);\r\n```\r\n\r\nThanks for any help. Lmk if you need more context. \r\n"},"comment":{"url":"https://api.github.com/repos/kirill-konshin/next-redux-wrapper/issues/comments/394594472","html_url":"https://github.com/kirill-konshin/next-redux-wrapper/issues/90#issuecomment-394594472","issue_url":"https://api.github.com/repos/kirill-konshin/next-redux-wrapper/issues/90","id":394594472,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDU5NDQ3Mg==","user":{"login":"andrewmclagan","id":1073259,"node_id":"MDQ6VXNlcjEwNzMyNTk=","avatar_url":"https://avatars2.githubusercontent.com/u/1073259?v=4","gravatar_id":"","url":"https://api.github.com/users/andrewmclagan","html_url":"https://github.com/andrewmclagan","followers_url":"https://api.github.com/users/andrewmclagan/followers","following_url":"https://api.github.com/users/andrewmclagan/following{/other_user}","gists_url":"https://api.github.com/users/andrewmclagan/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewmclagan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewmclagan/subscriptions","organizations_url":"https://api.github.com/users/andrewmclagan/orgs","repos_url":"https://api.github.com/users/andrewmclagan/repos","events_url":"https://api.github.com/users/andrewmclagan/events{/privacy}","received_events_url":"https://api.github.com/users/andrewmclagan/received_events","type":"User","site_admin":false},"created_at":"2018-06-05T06:18:26Z","updated_at":"2018-06-05T06:18:26Z","author_association":"NONE","body":"yeah also got confused with the naming."}}
{"actor":{"display_login":"andrewmclagan"}}