From ef92eea6aa67396c154f59a409bf578bef7611f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDiga=20Kra=C5=A1ovec?= Date: Thu, 28 Sep 2023 09:26:14 +0200 Subject: [PATCH] fix: Prevent crash when this.canvas is null in the componentWillUnmount method --- src/index.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.jsx b/src/index.jsx index 36b44aa..3d4f428 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -56,8 +56,10 @@ class LinesEllipsis extends React.Component { } componentWillUnmount () { - this.canvas.parentNode.removeChild(this.canvas) - this.canvas = null + if (this.canvas) { + this.canvas.parentNode.removeChild(this.canvas) + this.canvas = null + } } setState (state, callback) {