Skip to content

[Bug] useModel依赖Executor的useEffect进行状态更新,导致批处理行为不符合预期 #13140

@karthest

Description

@karthest

What happens?

由于useModel通过Executor的useEffect做状态同步,导致和useState混用时未充分使用react的批处理能力

Mini Showcase Repository(REQUIRED)

Please provide a minimal reproduction then upload to your GitHub. 请提供 最小重现,并上传到你的 GitHub 仓库

最小重现

How To Reproduce

Steps to reproduce the behavior:

  1. 某组件中使用useState和useModel
  2. 将useState和useModel的state放在同一个useEffect的依赖数组中
  3. 在React的事件监听中同时修改useState和useModel的state

Expected behavior

  1. 期望充分利用react的批处理机制导致useEffect只触发一次

Context

  • Umi Version: v.4.5.0
  • Node Version: v20.17.0
  • Platform: macOS Tahoe 26.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions