Closed sunny-token closed 8 months ago
@jaywcjlove 好像用了icon后会导致副作用一直在刷,能帮忙看下吗?
@sunny-token 如果你提供可以重现错误的示例,我可以帮你看看
我上面的demo链接就是例子哦,你帮忙看看呢
---原始邮件--- 发件人: @.> 发送时间: 2024年1月23日(周二) 晚上7:33 收件人: @.>; 抄送: @.**@.>; 主题: Re: [uiwjs/react-baidu-map] 使用useMarker后发现后台一直在刷警告 (Issue #322)
@sunny-token 如果你提供可以重现错误的示例,我可以帮你看看
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
@sunny-token 使用 useMemo
可以解决这个问题
const icon = useMemo(() => {
return new BMap.Icon(
"http://developer.baidu.com/map/jsdemo/img/fox.gif",
new BMap.Size(300, 157),
);
}, [])
好的,我试试,谢谢
---原始邮件--- 发件人: @.> 发送时间: 2024年1月23日(周二) 晚上8:20 收件人: @.>; 抄送: @.**@.>; 主题: Re: [uiwjs/react-baidu-map] 使用useMarker后发现后台一直在刷警告 (Issue #322)
@sunny-token 使用 useMemo 可以解决这个问题 const icon = useMemo(() => { return new BMap.Icon( "http://developer.baidu.com/map/jsdemo/img/fox.gif", new BMap.Size(300, 157), ); }, [])
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
可以了,用usememo解决了
const icon = new BMap.Icon('http://developer.baidu.com/map/jsdemo/img/fox.gif', new BMap.Size(300, 157)); useMarker({ map, position: NJ, icon: icon }); 不使用icon没问题,使用了icon后,后台一直刷warring,麻烦看下是啥问题呢?
具体例子下面链接。 demo