2efee94586cfcb53d119d61ca3af0a5d.json
5.26 KB
{"ast":null,"code":"var _interopRequireDefault=require(\"@babel/runtime/helpers/interopRequireDefault\");Object.defineProperty(exports,\"__esModule\",{value:true});exports.default=withNavigation;var _extends2=_interopRequireDefault(require(\"@babel/runtime/helpers/extends\"));var _classCallCheck2=_interopRequireDefault(require(\"@babel/runtime/helpers/classCallCheck\"));var _createClass2=_interopRequireDefault(require(\"@babel/runtime/helpers/createClass\"));var _possibleConstructorReturn2=_interopRequireDefault(require(\"@babel/runtime/helpers/possibleConstructorReturn\"));var _getPrototypeOf2=_interopRequireDefault(require(\"@babel/runtime/helpers/getPrototypeOf\"));var _inherits2=_interopRequireDefault(require(\"@babel/runtime/helpers/inherits\"));var _react=_interopRequireDefault(require(\"react\"));var _hoistNonReactStatics=_interopRequireDefault(require(\"hoist-non-react-statics\"));var _invariant=_interopRequireDefault(require(\"../utils/invariant\"));var _NavigationContext=_interopRequireDefault(require(\"./NavigationContext\"));var _jsxFileName=\"/Users/satya/Workspace/Callstack/react-navigation-core/src/views/withNavigation.js\";function withNavigation(Component){var config=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{forwardRef:true};var ComponentWithNavigation=function(_React$Component){(0,_inherits2.default)(ComponentWithNavigation,_React$Component);function ComponentWithNavigation(){(0,_classCallCheck2.default)(this,ComponentWithNavigation);return(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(ComponentWithNavigation).apply(this,arguments));}(0,_createClass2.default)(ComponentWithNavigation,[{key:\"render\",value:function render(){var _this=this;var navigationProp=this.props.navigation;return _react.default.createElement(_NavigationContext.default.Consumer,{__source:{fileName:_jsxFileName,lineNumber:17}},function(navigationContext){var navigation=navigationProp||navigationContext;(0,_invariant.default)(!!navigation,'withNavigation can only be used on a view hierarchy of a navigator. The wrapped component is unable to get access to navigation from props or context.');return _react.default.createElement(Component,(0,_extends2.default)({},_this.props,{navigation:navigation,ref:config.forwardRef?_this.props.onRef:undefined,__source:{fileName:_jsxFileName,lineNumber:25}}));});}}]);return ComponentWithNavigation;}(_react.default.Component);ComponentWithNavigation.displayName=\"withNavigation(\"+(Component.displayName||Component.name)+\")\";return(0,_hoistNonReactStatics.default)(ComponentWithNavigation,Component);}","map":{"version":3,"sources":["withNavigation.js"],"names":["config","forwardRef","ComponentWithNavigation","React","Component","navigationProp","navigation","invariant","hoistStatics"],"mappings":"qtBAAA,oDACA,qFACA,qEACA,8E,sGAEe,QAAA,CAAA,cAAA,CAAA,SAAA,CAGb,CADAA,GAAAA,CAAAA,MACA,CAAA,SAAA,CAAA,MAAA,CAAA,CAAA,EAAA,SAAA,CAAA,CAAA,CAAA,GAAA,SAAA,CAAA,SAAA,CAAA,CAAA,CAAA,CADS,CAAEC,UAAU,CAAZ,IAAA,CAATD,CACA,GACME,CAAAA,uBADN,CAAA,SAAA,gBAAA,CAAA,CAAA,uBAAA,uBAAA,CAAA,gBAAA,EAAA,QAAA,CAAA,uBAAA,EAAA,CAAA,6BAAA,IAAA,CAAA,uBAAA,EAAA,MAAA,wCAAA,IAAA,CAAA,6BAAA,uBAAA,EAAA,KAAA,CAAA,IAAA,CAAA,SAAA,CAAA,CAAA,CAAA,2BAAA,uBAAA,CAAA,CAAA,CAAA,GAAA,CAAA,QAAA,CAAA,KAAA,CAAA,QAAA,CAAA,MAAA,EAKW,CAAA,GAAA,CAAA,KAAA,CAAA,IAAA,CACP,GAAMG,CAAAA,cAAc,CAAG,KAAA,KAAA,CAAvB,UAAA,CACA,MACE,gBAAA,aAAA,CAAA,2BAAA,QAAA,CAAA,CAAA,QAAA,CAAA,CAAA,QAAA,CAAA,YAAA,CAAA,UAAA,CAAA,EAAA,CAAA,CAAA,CACG,SAAA,iBAAA,CAAqB,CACpB,GAAMC,CAAAA,UAAU,CAAGD,cAAc,EAAjC,iBAAA,CACAE,uBACE,CAAC,CADM,UAATA,CAAAA,wJAAAA,EAIA,MACE,gBAAA,aAAA,CAAA,SAAA,CAAA,sBAAA,EAAA,CACM,KAAI,CADV,KAAA,CAAA,CAEE,UAAU,CAFZ,UAAA,CAGE,GAAG,CAAEP,MAAM,CAANA,UAAAA,CAAoB,KAAI,CAAJ,KAAA,CAApBA,KAAAA,CAHP,SAAA,CAAA,QAAA,CAAA,CAAA,QAAA,CAAA,YAAA,CAAA,UAAA,CADF,EACE,CAAA,CAAA,CAAA,CADF,CARN,CACE,CADF,CAPJ,CAAA,CAAA,CAAA,EAAA,MAAA,CAAA,uBAAA,CAAA,CAAA,CACsCG,eADtC,SAAA,CAAA,CACMD,uBADN,CAAA,WACMA,CADN,mBAEyCE,SAAS,CAATA,WAAAA,EACrCA,SAAS,CAHb,IAAA,EAAA,GACMF,CA2BN,MAAOM,kCAAY,uBAAZA,CAAP,SAAOA,CAAP,CACD","sourcesContent":["import React from 'react';\nimport hoistStatics from 'hoist-non-react-statics';\nimport invariant from '../utils/invariant';\nimport NavigationContext from './NavigationContext';\n\nexport default function withNavigation(\n Component,\n config = { forwardRef: true }\n) {\n class ComponentWithNavigation extends React.Component {\n static displayName = `withNavigation(${Component.displayName ||\n Component.name})`;\n\n render() {\n const navigationProp = this.props.navigation;\n return (\n <NavigationContext.Consumer>\n {navigationContext => {\n const navigation = navigationProp || navigationContext;\n invariant(\n !!navigation,\n 'withNavigation can only be used on a view hierarchy of a navigator. The wrapped component is unable to get access to navigation from props or context.'\n );\n return (\n <Component\n {...this.props}\n navigation={navigation}\n ref={config.forwardRef ? this.props.onRef : undefined}\n />\n );\n }}\n </NavigationContext.Consumer>\n );\n }\n }\n\n return hoistStatics(ComponentWithNavigation, Component);\n}\n"]},"metadata":{},"sourceType":"script"}