Skip to content

Commit

Permalink
fix: 限制provider监听唯一
Browse files Browse the repository at this point in the history
  • Loading branch information
linjinze999 committed Aug 29, 2024
1 parent 956bcd9 commit 662eec9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/hippy_ui_react/src/provider/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export default class Provider extends Component<PropsWithChildren<ProviderProps>
};

componentDidMount() {
if (!this.props.noGlobalView) {
if (!this.props.noGlobalView && !Provider.hasListenGlobalView) {
Provider.hasListenGlobalView = true;
HRUEvent.on(HRU_EVENT_GLOBAL_VIEW, this.listenGlobalView);
ConfigCommon.commonListenBackAdd?.(this.backToCloseGlobalView);
}
Expand All @@ -42,6 +43,11 @@ export default class Provider extends Component<PropsWithChildren<ProviderProps>
HRUEvent.emit(HRU_EVENT_GLOBAL_VIEW, params);
}

/**
* 记录已经监听全局节点插入事件
* */
static hasListenGlobalView = false;

// state更新不及时,这里用变量来记录最新值
private realTimeGlobalViews: UpdateGlobalViewData = {};

Expand Down

0 comments on commit 662eec9

Please sign in to comment.