Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [Bug]: 因 dataSourceMap 绑定到 this 中的时机“滞后”引发的异常 #1138

Open
leishanglin opened this issue Feb 24, 2025 · 1 comment · May be fixed by #1142
Open

🐛 [Bug]: 因 dataSourceMap 绑定到 this 中的时机“滞后”引发的异常 #1138

leishanglin opened this issue Feb 24, 2025 · 1 comment · May be fixed by #1142
Labels
bug Something isn't working

Comments

@leishanglin
Copy link

leishanglin commented Feb 24, 2025

Environment

develop

Version

v22.11.0

Version

latest(v2.3.0-rc.0)

Link to minimal reproduction

none

Step to reproduce

  1. 在一个空白页面中拖入一个 Collection 组件,然后绑定一个已存在的数据源,比如:getAllList
  2. 再在 Collection 中拖入一个 TinyGrid 组件;
  3. 点击右上角“保存”,然后立刻刷新这个浏览器标签页;就会出现以下报错。原因是 JS 中的 this.dataSourceMap 为 undefined
Image

经排查,问题发生在:packages/canvas/render/src/RenderMain.ts;

Image

如上图所示,在浏览器标签页加载时,setSchema(window.host.getSchema()) 会先于 setDataSourceMap(data) 执行,导致 getDataSourceMap 先于 setDataSourceMap 执行,从而引发 undefined.

该问题的内部作用机制我不清楚,但发现了一个可以“规避”的方法:使用 setTimeout 改变 setSchema(window.host.getSchema()) 的触发时机,这样就不会报错了。但这种方式并不好,希望各位大佬能看看怎么优雅的解决。

Image

Image

What is expected

.

What is actually happening

.

What is your project name

none

Any additional comments (optional)

No response

@leishanglin leishanglin changed the title 🐛 [Bug]: 🐛 [Bug]: 因 dataSourceMap 绑定到 this 中的时机“滞后”引发的异常 Feb 24, 2025
@chilingling chilingling added the bug Something isn't working label Feb 24, 2025
@chilingling chilingling linked a pull request Feb 24, 2025 that will close this issue
14 tasks
@chilingling chilingling linked a pull request Feb 24, 2025 that will close this issue
14 tasks
@leishanglin
Copy link
Author

@chilingling Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants