Skip to content

[effector-react/scope]: useUnit Bug  #817

@7iomka

Description

@7iomka

What is the current behavior:
Units used with useUnit from effector-react/scope in next.js project is most likely has batching in the wrong way, and maybe for this reason when navigating when scope changes, in a certain case, these units lose synchronization and are no longer available for use.
In my case I have a simple toggler factory, so it is broken when you navigate to the same page.

DEMO LINK

Please provide the steps to reproduce and if possible a minimal demo of the problem via https://share.effector.dev, https://codesandbox.io or similar

  1. Open demo link
  2. Click to hamburger button to see that drawer that use the $isOpen, toggle, ... state from toggler instance works correctly
  3. Click to GO_TO_THIS_PAGE_AGAIN link, and try to open hamburger menu again - it's broken now

Any another cases of navigation don't produce this issue:

  1. Click to Go to another page link and repeat step 2 to see that all still works.
  2. From page from step 3 you can go back to home page in 2 ways - 1st - with router events, 2nd - directly with link - all works fine as expected

What is the expected behavior:
I expected that useUnit have the same behavior as useStore/useEvent.
Because, if we will use it as a replacement for useUnit, the issue is gone.
Demo with useStore/useEvent without described bug: LINK HERE

Which versions of effector packages, and which browser and OS are affected by this issue? Did this work in previous versions of effector?:
All latest versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnextjsIntegration with next.js framework

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions