Can somebody explain how the module system in react navigation works? There are getters inside module.exports (with node.js-like require()), and also es6 style export default in other files. I completely stuck how to make sense of it. I tried to look into git history, but the initial git commit (first public release) already had this solution in place.
The main file (src/react-navigation.js
):
module.exports = {
get createKeyboardAwareNavigator() {
return require('@react-navigation/native').createKeyboardAwareNavigator;
},
};
react-navigation-native/src/createKeyboardAwareNavigator.js:
export default (Navigator, navigatorConfig) =>
class KeyboardAwareNavigator extends React.Component {
};
So why
1. there is module.exports instead of export?
2. why there is a getter inside module.exports
?
3. how can require
and export default
be mixed?