fix(dev exp): auto disable fast refresh on iOS (#20120)

This commit is contained in:
yqrashawn 2024-05-23 15:17:01 +08:00 committed by GitHub
parent 60ef4fab4b
commit c19f170239
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,6 @@
(ns status-im.setup.dev (ns status-im.setup.dev
(:require (:require
["react-native" :refer (DevSettings LogBox)] ["react-native" :refer (DevSettings LogBox NativeModules)]
[react-native.platform :as platform] [react-native.platform :as platform]
[status-im.setup.schema :as schema] [status-im.setup.schema :as schema]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -48,9 +48,15 @@
:json-rpc/call}) :json-rpc/call})
(when ^:boolean js/goog.DEBUG (when ^:boolean js/goog.DEBUG
(schema/setup!) (schema/setup!)
(when (and platform/ios? DevSettings) (when platform/ios?
;;on Android this method doesn't work ;; on Android this method doesn't work
(when-let [nm (.-_nativeModule DevSettings)] (when-let [setHotLoadingEnabled (or
(and NativeModules
(.-DevSettings NativeModules)
(.-setHotLoadingEnabled (.-DevSettings NativeModules)))
(and DevSettings
(.-_nativeModule DevSettings)
(.-setHotLoadingEnabled (.-_nativeModule DevSettings))))]
;;there is a bug in RN, so we have to enable it first and then disable ;;there is a bug in RN, so we have to enable it first and then disable
(.setHotLoadingEnabled ^js nm true) (setHotLoadingEnabled true)
(js/setTimeout #(.setHotLoadingEnabled ^js nm false) 1000))))) (js/setTimeout #(setHotLoadingEnabled false) 1000)))))