zalmoxisus / redux-devtools-extension

Redux DevTools extension.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

options.instanceId doesn't support Symbols as instance name.

senadir opened this issue · comments

Initiating __REDUX_DEVTOOLS_EXTENSION__.options.instanceId with a symbol would throw an error.

Uncaught DOMException: Failed to execute 'postMessage' on 'Window': Symbol(wc/store/cart) could not be cloned.
    at post (<anonymous>:13794:10)
    at toContentScript (<anonymous>:13885:3)
    at relay (<anonymous>:14240:5)
    at init (<anonymous>:14440:5)

Use case:
I'm using redux devtools alongside @wordpress/data, which is a superset of redux that supports multiple stores along other things.
@wordpress/data register each store with __REDUX_DEVTOOLS_EXTENSION__, using the store name as the name and instanceId for the plugin.

image

Reproduce steps:
You can see this example https://codesandbox.io/s/silent-silence-fknrn?file=/src/index.js

Basically:

import { createStore } from "redux";
import { devToolsEnhancer } from "redux-devtools-extension";

const store = createStore(
  () => {},
  devToolsEnhancer({
    instanceId: Symbol("test")
  })
);

Possible fixes:

  • Detect if instanceId is a symbol typeof instanceId === 'symbol' and serialize it instanceId.toString() which would give you 'Symbol("test")'.

Just pinging to see if there's any chance of getting this merged any time soon?