UNPKG

@td-design/react-native-tabs

Version:

基于 @td-design/react-native 的 tabs 组件

38 lines 1.01 kB
import React, { useEffect } from 'react'; import { View } from 'react-native'; import { useSafeState } from '@td-design/rn-hooks'; export default function SceneView(_ref) { let { lazy, currentPage, index, children } = _ref; const [isLoading, setIsLoading] = useSafeState(lazy && Math.abs(currentPage - index) > 0); if (isLoading && Math.abs(currentPage - index) <= 0 && lazy) { setIsLoading(false); } useEffect(() => { let timer; if (!lazy && isLoading) { timer = setTimeout(() => { setIsLoading(false); }, 0); } return () => { clearTimeout(timer); }; }, [lazy, isLoading]); const focused = currentPage === index; return /*#__PURE__*/React.createElement(View, { accessibilityElementsHidden: !focused, importantForAccessibility: focused ? 'auto' : 'no-hide-descendants', style: { flex: 1, overflow: 'hidden' } }, children({ loading: isLoading })); } //# sourceMappingURL=SceneView.js.map