use-safe-unmount for hot reload (#20450)

This commit is contained in:
flexsurfer 2024-06-13 15:23:01 +02:00 committed by GitHub
parent dc335cc333
commit 60b3d01ceb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -95,3 +95,10 @@
[rn/activity-indicator {:animating true}]]
[rn/text {:style {:margin-top 10 :color (if @warning? :red :black)}}
@label]])))
(defn use-safe-unmount
[handler]
(let [prev-cnt @cnt]
(if js/goog.DEBUG
(rn/use-unmount #(when (= prev-cnt @cnt) (handler)))
(rn/use-unmount handler))))