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

microApp.setData多次只会拿到一个type数据,为什么旧数据还合并过来啊 #1356

Closed
xian107 opened this issue Sep 10, 2024 · 2 comments
Labels
Need Reproduction 需要复现步骤

Comments

@xian107
Copy link

xian107 commented Sep 10, 2024

hooks1:useEffect(() => { microApp.setData(name, {path:xxx} }, [location.pathname]);
hooks2:useEffect(() => { microApp.setData(name, {tabArrs:xxx} }, [tabArrs]);
hooks1执行后,hooks2执行了后倒置监听到的数据包含hooks1的path,把数据合并了,我在子应用无法知道哪些数据有更新。

改成:
hooks1:useEffect(() => { microApp.setData(name, {type:'path',payload:xxx} }, [location.pathname]);
hooks2:useEffect(() => { microApp.setData(name, {type:'tabArrs',,payload:xxx} }, [tabArrs]);
两个一起变化的时候,我在子应用只能拿到后面执行的type

请问我在子应用要怎么才能addDataListener到最新变化的值?不要之前的旧值

下面这种方法也不行,因为不确定hooks1和hooks2哪个先。都是用useEffect监听的,不在同一个组件里
microApp.setData('my-app', {city: 'HK'}, (res: any[]) => {
microApp.setData('my-app')
})

@timhub66 timhub66 added the Need Reproduction 需要复现步骤 label Sep 10, 2024
Copy link

Hello @xian107. In order to facilitate location and troubleshooting, we need you to provide a realistic GitHub repository.
您好 @xian107, 为了方便定位和排查问题,我们需要您提供一个重现实例,请提供一个尽可能精简的 GitHub 仓库地址。

Copy link

Since the issue was labeled with Need Reproduction, but no response in 7 days. This issue will be close. If you have any questions, you can comment and reply.
由于该 issue 被标记为需要可复现步骤,却 7 天未收到回应。现关闭 issue,若有任何问题,可评论回复。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Need Reproduction 需要复现步骤
Projects
None yet
Development

No branches or pull requests

2 participants