3

Is there a variable that exposes the ID / count of the current hot reload in React Native, or alternatively any other way of detecting a hot reload?

For context, I have a dynamic require behind a reselect selector which doesn't get invalidated when one of the required files changes. I can work around the problem by using a less efficient implementation when __DEV__ is true, but I'd prefer something that I can add as a selector dependency.

Richard Szalay
  • 83,269
  • 19
  • 178
  • 237
  • i don't think right now there is any way. you can open an issue here https://github.com/facebook/react-native/issues – mehulmpt May 08 '17 at 08:02

1 Answers1

3

On iOS, I was able to use the RCTBridgeWillReloadNotification event:

NotificationCenter.default.addObserver(
  self,
  selector: #selector(self.test),
  name: NSNotification.Name(rawValue: "RCTBridgeWillReloadNotification"),
  object: nil)
Heinrisch
  • 5,835
  • 4
  • 33
  • 43