Skip to content

The state is patched twice if the extension is opened in a separate tab #311

@EgorKazachenko

Description

@EgorKazachenko

const serializedMessagePoster = withSerializer(serializer)((...args) => {

Hi, thanks for amazing library. I get the wrong behavior when i open my extension as a separate browser tab. Due to this code

browserAPI.runtime.sendMessage(...args, onErrorCallback);
  // We will broadcast state changes to all tabs to sync state across content scripts
  return browserAPI.tabs.query({}, (tabs) => {
    for (const tab of tabs) {
      browserAPI.tabs.sendMessage(tab.id, ...args, onErrorCallback);
    }
  });

My UI's store getting same patch twice and as i use custom diff/patch strategy (works like a regular redux without IPC de/serialization issues) for my useEffect's etc. it's a bit unexcpected for example when some item is added to some list inside the state and replaced by the item with the same structure but with a different refference right after. "remove" patch works even more fun :)

Could you please clarify if this is intended or is it a bug?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions