From 9ab4a777d6be2e61977c844ebd3024bafd76816b Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Fri, 9 Jul 2021 16:26:15 +0800 Subject: [PATCH] fix: safely remove style --- src/stylesheet-registry.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/stylesheet-registry.js b/src/stylesheet-registry.js index a3e2593f..2639c8ac 100644 --- a/src/stylesheet-registry.js +++ b/src/stylesheet-registry.js @@ -68,10 +68,9 @@ export default class StyleSheetRegistry { remove(props) { const { styleId } = this.getIdAndRules(props) - invariant( - styleId in this._instancesCounts, - `styleId: \`${styleId}\` not found` - ) + const hasId = styleId in this._instancesCounts + if (!hasId) return + this._instancesCounts[styleId] -= 1 if (this._instancesCounts[styleId] < 1) { @@ -211,9 +210,3 @@ export default class StyleSheetRegistry { }, {}) } } - -function invariant(condition, message) { - if (!condition) { - throw new Error(`StyleSheetRegistry: ${message}.`) - } -}