From 0374f544fa5c51a8e96e10047174a3cfff89b117 Mon Sep 17 00:00:00 2001 From: Elaina Cherudim Date: Thu, 7 Sep 2023 15:41:50 +0800 Subject: [PATCH] Update register-scope.ts Add warning when user renders multiple ModalContainer with same or no scope. If one of the ModalContainer is unregistered, modals with that scope name won't be shown until next time the ModalContainer of the same scope name is rendered again. --- src/utils/register-scope.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils/register-scope.ts b/src/utils/register-scope.ts index b2cb5c7..6645599 100644 --- a/src/utils/register-scope.ts +++ b/src/utils/register-scope.ts @@ -15,6 +15,9 @@ if (typeof window !== 'undefined') { } export const registerContainer = (scope: Scope, ref: ContainerRef) => { + if (window[SCOPE_KEY][scope]) { + console.warn('Duplicated scope detected, scope: ' + scope + ' has already been registered, multiple instance of ModalContainer may cause unpredictable behaviors!') + } window[SCOPE_KEY][scope] = ref return ref