Sharing Redux state to other clients doesn't work when stringified

Viewed 274

I am directly sending a redux state from one client to another by simple converting objects to string and sending over websocket and received and parsing and dispatching to store.

The issue is if object is like this :

"{"type":"some_action","uid":"1","updates":{"attributes":{"content":["hello"]}}}"

then it works fine but if let's say object is like this :

enter image description here

then i get the error on other client : https://facebook.github.io/react/docs/error-decoder.html?invariant=31&args%5B%5D=object%20with%20keys%20%7Btype%2C%20key%2C%20ref%2C%20props%2C%20_owner%7D&args%5B%5D=

which states object are not valid as react client. Here is stringified version of object in image.

{
  "type": "some_action",
  "uid": "1",
  "updates": {
    "attributes": {
      "content": [
        {
          "type": "em",
          "key": "_domReact2",
          "ref": null,
          "props": {
            "children": {
              "type": "strong",
              "key": "_domReact1",
              "ref": null,
              "props": {
                "children": "a"
              },
              "_owner": null
            }
          },
          "_owner": null
        }
      ]
    }
  }
}

Please see that props can be nested here. I tried a hack which is created a null React.creatElement and merged two object so that i have missing '$$typeof' key and it worked, but i am looking for better way or answers from the community. Thanks!

1 Answers
Related