{"version":3,"sources":["webpack://_N_E/./components/loading.tsx","webpack://_N_E/./node_modules/invariant/browser.js","webpack://_N_E/./components/ad/index.tsx","webpack://_N_E/./components/hooks/use-visible.ts","webpack://_N_E/./node_modules/react-intersection-observer/node_modules/@babel/runtime/helpers/esm/extends.js","webpack://_N_E/./node_modules/react-intersection-observer/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js","webpack://_N_E/./node_modules/react-intersection-observer/node_modules/@babel/runtime/helpers/esm/defineProperty.js","webpack://_N_E/./node_modules/react-intersection-observer/react-intersection-observer.esm.js","webpack://_N_E/./node_modules/react-intersection-observer/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://_N_E/./node_modules/react-intersection-observer/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js","webpack://_N_E/./components/scroll-loader.tsx"],"names":["Loading","module","exports","condition","format","a","b","c","d","e","f","error","undefined","Error","args","argIndex","replace","name","framesToPop","useAdStat","eventName","info","customStat","throttleTime","useInView","threshold","ref","inView","isVisible","useVisible","adData","useMemo","ad_material_id","materiel_str","ad_target_url","web_url","log_extra","ad_id","id_str","ad_req_id","JSON","parse","req_id","sendRef","useRef","showTimer","useEffect","current","send","sendTeaAdEvent","show","track_url_list","forEach","url","sendAdMonitor","requestId","ad_log_id","eventId","window","setTimeout","handleClick","useCallback","custom","click","click_track_url_list","useContext","GlobalStoreContext","state","_extends","Object","assign","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","this","_assertThisInitialized","self","ReferenceError","_defineProperty","obj","value","defineProperty","enumerable","configurable","writable","INSTANCE_MAP","Map","OBSERVER_MAP","ROOT_IDS","consecutiveRootId","observe","element","callback","options","_options","root","rootMargin","has","observerId","get","set","toString","getRootId","observerInstance","IntersectionObserver","onChange","instance","observer","thresholds","Array","isArray","unobserve","itemsLeft","rootObserved","item","disconnect","changes","intersection","isIntersecting","intersectionRatio","some","_React$Component","subClass","superClass","InView","_this","_len","_key","concat","entry","node","observeNode","setState","props","create","constructor","__proto__","_proto","componentDidMount","componentDidUpdate","prevProps","prevState","triggerOnce","componentWillUnmount","_this$props","handleChange","render","_this$state","children","isPlainChildren","handleNode","_this$props2","as","tag","excluded","sourceKeys","keys","indexOf","_objectWithoutPropertiesLoose","_React$useState","setRef","ScrollLoader","React","verticalMargin","change","end","loading","loadMoreHandler","dom","HEIGHT","document","documentElement","clientHeight","addObserver","removeObserver","style","height"],"mappings":"6JAyDeA,IAvDC,kBACd,qCACE,6CACE,8CACA,8CACA,8CACA,mEALJ,2nC,kCC6CFC,EAAOC,QA5BS,SAASC,EAAWC,EAAQC,EAAGC,EAAGC,EAAGC,EAAGC,EAAGC,GAOzD,IAAKP,EAAW,CACd,IAAIQ,EACJ,QAAeC,IAAXR,EACFO,EAAQ,IAAIE,MACV,qIAGG,CACL,IAAIC,EAAO,CAACT,EAAGC,EAAGC,EAAGC,EAAGC,EAAGC,GACvBK,EAAW,GACfJ,EAAQ,IAAIE,MACVT,EAAOY,QAAQ,OAAO,WAAa,OAAOF,EAAKC,UAE3CE,KAAO,sBAIf,MADAN,EAAMO,YAAc,EACdP,K,+xBCFH,IAAMQ,EAAwB,SACnCC,EACAC,EACAC,GAEG,IADHC,EACG,uDADY,IACZ,EACmBC,YAAU,CAC9BC,UAAW,IAFV,mBACIC,EADJ,KACSC,EADT,KAIGC,EAAYC,cACZC,EAASC,mBAAQ,WACrB,UACEC,eAAgBX,EAAKY,aACrBC,cAAeb,EAAKc,QACpBC,UAAWf,EAAKe,UAChBC,MAAOhB,EAAKiB,OACZC,UAAWC,KAAKC,MAAMpB,EAAKe,WAAWM,QACnCpB,KAEJ,CAACA,EAAYD,EAAKiB,OAAQjB,EAAKe,UAAWf,EAAKY,aAAcZ,EAAKc,UAC/DQ,EAAUC,kBAAO,GACjBC,EAAYD,mBAClBE,qBAAU,WACJhB,IAAWa,EAAQI,SAAW3B,EAAU4B,OAE1CC,YAAe7B,EAAU4B,KAAMlB,GAC/Ba,EAAQI,SAAU,KAEnB,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AAe,UAEvCA,EAAgB,EAAQ,eAAgB,CACtC5D,UAAW,EACX4H,aAAa,K,4rBGtRMmB,E,uOAKY,M,oCAEd,G,iCAEHC,e,0CAqBQ,WAAM,MACM,EAAK7B,MAA7B8B,sBADkB,MACD,GADC,EAE1B,EAAKxD,SAAW,IAAIH,sBAClB,SAAAY,GACEA,EAAQvE,SAAQ,SAAAuH,GAEd,GAAKA,EAAO9C,eAAZ,CAFwB,MAKkB,EAAKe,MAAvCgC,EALgB,EAKhBA,IAAKC,EALW,EAKXA,QAASC,EALE,EAKFA,gBACjBF,GAAQC,GAGXC,UAIN,CACErJ,UAAW,CAAC,GACZ8E,WAAY,GAAF,OAAKmE,EAAL,aAGd,EAAKxD,SAASjB,QAAQ,EAAK8E,IAAIhI,Y,kEAxC/BkC,KAAK+F,OAASC,SAASC,gBAAgBC,aACvClG,KAAKmG,gB,yCAGYjC,GAA8B,IACvCyB,EAAQ3F,KAAK2D,MAAbgC,KAEHzB,EAAUyB,KAAOA,EACpB3F,KAAKoG,kBACIlC,EAAUyB,KAAQA,GAAQ3F,KAAKiC,UACxCjC,KAAKmG,gB,6CAKPnG,KAAKoG,mB,uCA6BDpG,KAAKiC,WACPjC,KAAKiC,SAASI,UAAUrC,KAAK8F,IAAIhI,SACjCkC,KAAKiC,SAAW,Q,+BAIX,IACCyC,EAAa1E,KAAK2D,MAAlBe,SACR,OACE,EAAC,WAAD,KACGA,EACD,SAAKjI,IAAKuD,KAAK8F,IAAKO,MAAO,CAAEC,OAAQ,c,GAnEHd","file":"static/chunks/e51918771e6e00d4139f976f7126c590f554ec64.8c6560acb562bcad5f2b.js","sourcesContent":["import * as React from 'react'\n\nconst Loading = () => (\n
\n
\n
\n
\n
\n 加载中…\n
\n \n
\n)\n\nexport default Loading\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\n/**\n * Use invariant() to assert state which your program assumes to be true.\n *\n * Provide sprintf-style format (only %s is supported) and arguments\n * to provide information about what broke and what you were\n * expecting.\n *\n * The invariant message will be stripped in production, but the invariant\n * will remain to ensure logic does not differ in production.\n */\n\nvar invariant = function(condition, format, a, b, c, d, e, f) {\n if (process.env.NODE_ENV !== 'production') {\n if (format === undefined) {\n throw new Error('invariant requires an error message argument');\n }\n }\n\n if (!condition) {\n var error;\n if (format === undefined) {\n error = new Error(\n 'Minified exception occurred; use the non-minified dev environment ' +\n 'for the full error message and additional helpful warnings.'\n );\n } else {\n var args = [a, b, c, d, e, f];\n var argIndex = 0;\n error = new Error(\n format.replace(/%s/g, function() { return args[argIndex++]; })\n );\n error.name = 'Invariant Violation';\n }\n\n error.framesToPop = 1; // we don't care about invariant's own frame\n throw error;\n }\n};\n\nmodule.exports = invariant;\n","import useVisible from 'Components/hooks/use-visible'\nimport { useInView } from 'react-intersection-observer'\nimport { useEffect, useMemo, useCallback, useRef } from 'react'\nimport { sendTeaAdEvent, sendAdMonitor } from 'lib/tea-analyze'\nimport { IDefaultAd } from './interface'\n// 根据广告数据返回对应的埋点数据\nexport function getAdStatData(info: IDefaultAd) {\n return {\n ad_material_id: info.materiel_str,\n ad_target_url: info.web_url,\n log_extra: info.log_extra,\n ad_id: info.id_str,\n ad_req_id: JSON.parse(info.log_extra).req_id,\n }\n}\n\ntype TUseAdStat = (\n eventName: {\n /**\n * 下发事件名\n */\n send: string\n /**\n * 展示事件名\n */\n show: string\n /**\n * 点击事件名\n */\n click: string\n },\n info: IDefaultAd,\n customStat?: {\n [key: string]: string | number\n },\n throttleTime?: number\n) => {\n ref(node?: Element | null | undefined): void\n handleClick(custom?: { [key: string]: string | number }): void\n}\n\n// 发送下发和展现事件\nexport const useAdStat: TUseAdStat = (\n eventName,\n info,\n customStat,\n throttleTime = 1000\n) => {\n const [ref, inView] = useInView({\n threshold: 0,\n })\n const isVisible = useVisible()\n const adData = useMemo(() => {\n return {\n ad_material_id: info.materiel_str,\n ad_target_url: info.web_url,\n log_extra: info.log_extra,\n ad_id: info.id_str,\n ad_req_id: JSON.parse(info.log_extra).req_id,\n ...customStat,\n }\n }, [customStat, info.id_str, info.log_extra, info.materiel_str, info.web_url])\n const sendRef = useRef(false)\n const showTimer = useRef()\n useEffect(() => {\n if (adData && !sendRef.current && eventName.send) {\n // 广告下发事件\n sendTeaAdEvent(eventName.send, adData)\n sendRef.current = true\n }\n }, [adData, eventName.send])\n useEffect(() => {\n // 广告展现事件\n // console.log(info.track_url_list, inView, isVisible, adData, eventName.show)\n if (inView && isVisible && eventName.show) {\n if (!showTimer.current) {\n sendTeaAdEvent(eventName.show, adData)\n if (info.track_url_list) {\n info.track_url_list.forEach(url => {\n sendAdMonitor({\n url,\n requestId: info.ad_log_id,\n eventId: eventName.show,\n })\n })\n }\n showTimer.current = window.setTimeout(() => {\n showTimer.current = 0\n }, throttleTime)\n }\n }\n }, [\n inView,\n isVisible,\n adData,\n eventName.show,\n info.track_url_list,\n info.ad_log_id,\n ])\n // 广告点击事件\n const handleClick = useCallback(\n (custom = {}) => {\n sendTeaAdEvent(eventName.click, {\n ...adData,\n ...custom,\n })\n if (info.click_track_url_list) {\n info.click_track_url_list.forEach(url => {\n sendAdMonitor({\n url,\n requestId: info.ad_log_id,\n eventId: eventName.click,\n })\n })\n }\n },\n [adData, eventName.click, info.ad_log_id, info.click_track_url_list]\n )\n\n return {\n ref,\n handleClick,\n }\n}\n","import { useContext } from 'react'\nimport { GlobalStoreContext } from 'Components/store'\nexport default function useVisible() {\n const { state } = useContext(GlobalStoreContext)\n return state.isVisible\n}\n","export default function _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}","export default function _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return self;\n}","export default function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}","import _extends from '@babel/runtime/helpers/esm/extends';\nimport _objectWithoutPropertiesLoose from '@babel/runtime/helpers/esm/objectWithoutPropertiesLoose';\nimport _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';\nimport _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';\nimport _defineProperty from '@babel/runtime/helpers/esm/defineProperty';\nimport { createElement, Component, useRef, useState, useCallback, useDebugValue } from 'react';\nimport invariant from 'invariant';\n\nvar INSTANCE_MAP = new Map();\nvar OBSERVER_MAP = new Map();\nvar ROOT_IDS = new Map();\nvar consecutiveRootId = 0;\n/**\n * Generate a unique ID for the root element\n * @param root\n */\n\nfunction getRootId(root) {\n if (!root) return '';\n if (ROOT_IDS.has(root)) return ROOT_IDS.get(root);\n consecutiveRootId += 1;\n ROOT_IDS.set(root, consecutiveRootId.toString());\n return ROOT_IDS.get(root) + '_';\n}\n/**\n * Monitor element, and trigger callback when element becomes inView\n * @param element {HTMLElement}\n * @param callback {Function} Called with inView\n * @param options {Object} InterSection observer options\n * @param options.threshold {Number} Number between 0 and 1, indicating how much of the element should be inView before triggering\n * @param options.root {HTMLElement}\n * @param options.rootMargin {String} The CSS margin to apply to the root element.\n */\n\n\nfunction observe(element, callback, options) {\n if (options === void 0) {\n options = {};\n }\n\n // IntersectionObserver needs a threshold to trigger, so set it to 0 if it's not defined.\n // Modify the options object, since it's used in the onChange handler.\n if (!options.threshold) options.threshold = 0;\n var _options = options,\n root = _options.root,\n rootMargin = _options.rootMargin,\n threshold = _options.threshold; // Validate that the element is not being used in another \n\n invariant(!INSTANCE_MAP.has(element), \"react-intersection-observer: Trying to observe %s, but it's already being observed by another instance.\\nMake sure the `ref` is only used by a single instance.\\n\\n%s\", element);\n /* istanbul ignore if */\n\n if (!element) return; // Create a unique ID for this observer instance, based on the root, root margin and threshold.\n // An observer with the same options can be reused, so lets use this fact\n\n var observerId = getRootId(root) + (rootMargin ? threshold.toString() + \"_\" + rootMargin : threshold.toString());\n var observerInstance = OBSERVER_MAP.get(observerId);\n\n if (!observerInstance) {\n observerInstance = new IntersectionObserver(onChange, options);\n /* istanbul ignore else */\n\n if (observerId) OBSERVER_MAP.set(observerId, observerInstance);\n }\n\n var instance = {\n callback: callback,\n element: element,\n inView: false,\n observerId: observerId,\n observer: observerInstance,\n // Make sure we have the thresholds value. It's undefined on a browser like Chrome 51.\n thresholds: observerInstance.thresholds || (Array.isArray(threshold) ? threshold : [threshold])\n };\n INSTANCE_MAP.set(element, instance);\n observerInstance.observe(element);\n return instance;\n}\n/**\n * Stop observing an element. If an element is removed from the DOM or otherwise destroyed,\n * make sure to call this method.\n * @param element {Element}\n */\n\nfunction unobserve(element) {\n if (!element) return;\n var instance = INSTANCE_MAP.get(element);\n\n if (instance) {\n var observerId = instance.observerId,\n observer = instance.observer;\n var root = observer.root;\n observer.unobserve(element); // Check if we are still observing any elements with the same threshold.\n\n var itemsLeft = false; // Check if we still have observers configured with the same root.\n\n var rootObserved = false;\n /* istanbul ignore else */\n\n if (observerId) {\n INSTANCE_MAP.forEach(function (item, key) {\n if (key !== element) {\n if (item.observerId === observerId) {\n itemsLeft = true;\n rootObserved = true;\n }\n\n if (item.observer.root === root) {\n rootObserved = true;\n }\n }\n });\n }\n\n if (!rootObserved && root) ROOT_IDS[\"delete\"](root);\n\n if (observer && !itemsLeft) {\n // No more elements to observe for threshold, disconnect observer\n observer.disconnect();\n } // Remove reference to element\n\n\n INSTANCE_MAP[\"delete\"](element);\n }\n}\n\nfunction onChange(changes) {\n changes.forEach(function (intersection) {\n var isIntersecting = intersection.isIntersecting,\n intersectionRatio = intersection.intersectionRatio,\n target = intersection.target;\n var instance = INSTANCE_MAP.get(target); // Firefox can report a negative intersectionRatio when scrolling.\n\n /* istanbul ignore else */\n\n if (instance && intersectionRatio >= 0) {\n // If threshold is an array, check if any of them intersects. This just triggers the onChange event multiple times.\n var inView = instance.thresholds.some(function (threshold) {\n return instance.inView ? intersectionRatio > threshold : intersectionRatio >= threshold;\n });\n\n if (isIntersecting !== undefined) {\n // If isIntersecting is defined, ensure that the element is actually intersecting.\n // Otherwise it reports a threshold of 0\n inView = inView && isIntersecting;\n }\n\n instance.inView = inView;\n instance.callback(inView, intersection);\n }\n });\n}\n\nfunction isPlainChildren(props) {\n return typeof props.children !== 'function';\n}\n/**\n * Monitors scroll, and triggers the children function with updated props\n *\n \n {({inView, ref}) => (\n

{`${inView}`}

\n )}\n
\n */\n\n\nvar InView =\n/*#__PURE__*/\nfunction (_React$Component) {\n _inheritsLoose(InView, _React$Component);\n\n function InView() {\n var _this;\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;\n\n _defineProperty(_assertThisInitialized(_this), \"state\", {\n inView: false,\n entry: undefined\n });\n\n _defineProperty(_assertThisInitialized(_this), \"node\", null);\n\n _defineProperty(_assertThisInitialized(_this), \"handleNode\", function (node) {\n if (_this.node) unobserve(_this.node);\n _this.node = node ? node : null;\n\n _this.observeNode();\n });\n\n _defineProperty(_assertThisInitialized(_this), \"handleChange\", function (inView, entry) {\n // Only trigger a state update if inView has changed.\n // This prevents an unnecessary extra state update during mount, when the element stats outside the viewport\n if (inView !== _this.state.inView || inView) {\n _this.setState({\n inView: inView,\n entry: entry\n });\n }\n\n if (_this.props.onChange) {\n // If the user is actively listening for onChange, always trigger it\n _this.props.onChange(inView, entry);\n }\n });\n\n return _this;\n }\n\n var _proto = InView.prototype;\n\n _proto.componentDidMount = function componentDidMount() {\n /* istanbul ignore else */\n if (process.env.NODE_ENV !== 'production') {\n invariant(this.node, \"react-intersection-observer: No DOM node found. Make sure you forward \\\"ref\\\" to the root DOM element you want to observe.\");\n }\n };\n\n _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {\n // If a IntersectionObserver option changed, reinit the observer\n if (prevProps.rootMargin !== this.props.rootMargin || prevProps.root !== this.props.root || prevProps.threshold !== this.props.threshold) {\n unobserve(this.node);\n this.observeNode();\n }\n\n if (prevState.inView !== this.state.inView) {\n if (this.state.inView && this.props.triggerOnce) {\n unobserve(this.node);\n this.node = null;\n }\n }\n };\n\n _proto.componentWillUnmount = function componentWillUnmount() {\n if (this.node) {\n unobserve(this.node);\n this.node = null;\n }\n };\n\n _proto.observeNode = function observeNode() {\n if (!this.node) return;\n var _this$props = this.props,\n threshold = _this$props.threshold,\n root = _this$props.root,\n rootMargin = _this$props.rootMargin;\n observe(this.node, this.handleChange, {\n threshold: threshold,\n root: root,\n rootMargin: rootMargin\n });\n };\n\n _proto.render = function render() {\n var _this$state = this.state,\n inView = _this$state.inView,\n entry = _this$state.entry;\n\n if (!isPlainChildren(this.props)) {\n return this.props.children({\n inView: inView,\n entry: entry,\n ref: this.handleNode\n });\n }\n\n var _this$props2 = this.props,\n children = _this$props2.children,\n as = _this$props2.as,\n tag = _this$props2.tag,\n triggerOnce = _this$props2.triggerOnce,\n threshold = _this$props2.threshold,\n root = _this$props2.root,\n rootMargin = _this$props2.rootMargin,\n props = _objectWithoutPropertiesLoose(_this$props2, [\"children\", \"as\", \"tag\", \"triggerOnce\", \"threshold\", \"root\", \"rootMargin\"]);\n\n return createElement(as || tag || 'div', _extends({\n ref: this.handleNode\n }, props), children);\n };\n\n return InView;\n}(Component);\n\n_defineProperty(InView, \"displayName\", 'InView');\n\n_defineProperty(InView, \"defaultProps\", {\n threshold: 0,\n triggerOnce: false\n});\n\n/* eslint-disable react-hooks/exhaustive-deps */\nfunction useInView(options) {\n if (options === void 0) {\n options = {};\n }\n\n var ref = useRef();\n\n var _React$useState = useState({\n inView: false,\n entry: undefined\n }),\n state = _React$useState[0],\n setState = _React$useState[1];\n\n var setRef = useCallback(function (node) {\n if (ref.current) {\n unobserve(ref.current);\n }\n\n if (node) {\n observe(node, function (inView, intersection) {\n setState({\n inView: inView,\n entry: intersection\n });\n\n if (inView && options.triggerOnce) {\n // If it should only trigger once, unobserve the element after it's inView\n unobserve(node);\n }\n }, options);\n } // Store a reference to the node\n\n\n ref.current = node;\n }, [options.threshold, options.root, options.rootMargin, options.triggerOnce]);\n useDebugValue(state.inView);\n return [setRef, state.inView, state.entry];\n}\n\nexport default InView;\nexport { InView, useInView };\n","export default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = superClass;\n}","export default function _objectWithoutPropertiesLoose(source, excluded) {\n if (source == null) return {};\n var target = {};\n var sourceKeys = Object.keys(source);\n var key, i;\n\n for (i = 0; i < sourceKeys.length; i++) {\n key = sourceKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n target[key] = source[key];\n }\n\n return target;\n}","import * as React from 'react'\nexport interface ScrollLoaderProps {\n // 判断是否正在加载中\n loading?: boolean\n /** 是否加载完毕 */\n end: boolean\n /** 垂直方向滚动的边界 */\n verticalMargin?: number\n /**\n * 加载执行的回调\n */\n loadMoreHandler(): void\n}\n\nexport default class ScrollLoader extends React.PureComponent<\n ScrollLoaderProps,\n {},\n any\n> {\n private observer: null | any = null\n\n private HEIGHT = 0\n\n private dom = React.createRef()\n\n componentDidMount() {\n this.HEIGHT = document.documentElement.clientHeight\n this.addObserver()\n }\n\n componentDidUpdate(prevProps: ScrollLoaderProps) {\n const { end } = this.props\n // 加载结束,卸载observer\n if (!prevProps.end && end) {\n this.removeObserver()\n } else if (prevProps.end && !end && !this.observer) {\n this.addObserver()\n }\n }\n\n componentWillUnmount() {\n this.removeObserver()\n }\n\n private addObserver = () => {\n const { verticalMargin = 10 } = this.props\n this.observer = new IntersectionObserver(\n changes => {\n changes.forEach(change => {\n // 某些浏览器intersectionRatio有问题,需要再判断位置\n if (!change.isIntersecting) {\n return\n }\n const { end, loading, loadMoreHandler } = this.props\n if (!end && !loading) {\n // 这里的loadMoreHandler一定要这样取,\n // 否则会导致跟hooks共用时的问题\n loadMoreHandler()\n }\n })\n },\n {\n threshold: [0],\n rootMargin: `${verticalMargin}px 10px`,\n }\n )\n this.observer.observe(this.dom.current)\n }\n\n private removeObserver() {\n if (this.observer) {\n this.observer.unobserve(this.dom.current)\n this.observer = null\n }\n }\n\n render() {\n const { children } = this.props\n return (\n \n {children}\n
\n \n )\n }\n}\n"],"sourceRoot":""}