Skip to content

Sync Problem between "not immediately opened tabs" #2

@reynnan

Description

@reynnan

If you open two tabs and one of this tab changes the state before the other one be opened, the second tab it will still initialize with the initValue that doesn't correspond anymore to the real value and if the second tabs change the state it will override the changes made by the first one.

Example:
Using the increment example in the README:

  1. Open the first tab and click to increment + 1
  2. Now open a second tab, it'll show the count as 0 and if you click increment it will "ignore" the first tab change and count as 1 again.

This is not very good when you state depends on the previous state

Possible Solution:
Maybe also save the state value on to use localStorage/sessionStorage and do?:

let initValue = checkOnLocalStorage() || initalState;
let [state, dispatch] = useReducer(reducer, initValue);

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