Skip to content

Commit

Permalink
fix: safely remove style
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Jul 9, 2021
1 parent 2741879 commit 9ab4a77
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/stylesheet-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -211,9 +210,3 @@ export default class StyleSheetRegistry {
}, {})
}
}

function invariant(condition, message) {
if (!condition) {
throw new Error(`StyleSheetRegistry: ${message}.`)
}
}

0 comments on commit 9ab4a77

Please sign in to comment.