in the source file / Libraries/react-native/react-native-implementation.js of react-native, all modules are exported as follows:
const ReactNative = {
// Components
get AccessibilityInfo() { return require("AccessibilityInfo"); },
get ActivityIndicator() { return require("ActivityIndicator"); },
...
}
here we use getter
to export, and perform require
operation inside the method. Does anyone know the difference between the above export method and the following export method?
const AccessibilityInfo = require("AccessibilityInfo");
const ActivityIndicator = require("ActivityIndicator");
const ReactNative = {
// Components
AccessibilityInfo,
ActivityIndicator
...
}
Thank you!