Skip to content

V2 to V3 Migration Guide

Çağdaş Tunca edited this page Oct 8, 2019 · 5 revisions

Please feel free to add any information that will help your fellow developers migrate from v2 to v3

BREAKING CHANGE LIST

Just as a start here are the notes from the CHANGELOG - I specifically welcome a detail of any return types that people notice are wildly different

  • BREAKING CHANGE: Every API call returns a Promise now (and thus no more Android constructor with async boolean argument)
    • This was required to improve module load speed, handle dynamic values, and release the main queue for iOS
    • If you must have a synchronous call (like during app bootstrap), use the parallel synchronous APIs labelled xxxSync()
  • BREAKING CHANGE: Every API call with acronyms ('getIP', 'getABI' etc) follows pure camel-case now (e.g. 'getIp', 'getAbi')
    • This naming style is a consensus standard. Previously APIs here were half one way half the other. Now they are consistent
    • isAirPlaneMode -> isAirplaneMode
    • getIPAddress -> getIpAddress
    • getMACAddress -> getMacAddress
    • getAPILevel -> getApiLevel
    • getBaseOS -> getBaseOs
    • getInstanceID -> getInstanceId
    • getUniqueID -> getUniqueId
    • supportedABIs -> supportedAbis
  • BREAKING CHANGE: all subscribable event names are prefixed with 'RNDeviceInfo_' (react-native-community/react-native-device-info/issues/620)
    • This is required as event names are a global namespace and collisions are inevitable otherwise
    • powerStateDidChange -> RNDeviceInfo_powerStateDidChange
    • batteryLevelDidChange -> RNDeviceInfo_batteryLevelDidChange
    • batteryLevelIsLow -> RNDeviceInfo_batteryLevelIsLow
  • BREAKING CHANGE: Android getBuildNumber returns string like iOS (react-native-community/react-native-device-info/pull/648)
  • BREAKING CHANGE: remove is24Hour, getTimezone, isAutoTimeZone and isAutoDateAndTime, getDeviceLocale, getDeviceCountry, getPreferredLocales
    • This was the result of a survey. It removes API duplication in the react-native-community modules
    • This is released in react-native-localize 1.2.0 - their README has the APIs to use native-localize.git and reference their new APIs usesAutoTimeZone + usesAutoDateAndTime (this should be released soon)
  • BREAKING CHANGE: iOS switch deprecated WebView for WebKit / getUserAgent returns Promise (react-native-community/react-native-device-info/pull/757)
    • The change from WebView to WebKit was required as the API is being removed from the iOS platform
  • BREAKING CHANGE: if an API is platform-specific, all non-implementing platforms will return standard values of -1, false, or 'unknown' depending on return type
    • This was how most APIs behaved before but it was not 100% - some returned null or empty string before getPhoneNumber sometimes returned null, now it will be 'unknown' if not known
Clone this wiki locally