mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-09 15:56:06 +08:00
fix(web): 补全缺失的 web shims 并修复渲染崩溃问题
- 新增 sentry-react-native、react-native-video、react-native-static-server、expo-network、expo-intent-launcher、expo-clipboard、expo-file-system 的 web shim - 重写 react-native-pager-view shim,通过 useImperativeHandle 暴露 setPage 方法 - 修复 sentry-react-native shim 缺少 ErrorBoundary 导致的渲染崩溃 - 在 _layout.tsx 中加载 Ionicons 字体,修复 web 端字体 404 - 更新 metro.config.js 中 sentry shim 路径为 .tsx
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* Web shim for react-native-pager-view.
|
||||
* eas update exports for web; this replaces the native-only module
|
||||
* with a simple View-based container that renders the first child only.
|
||||
* Supports setPage/setPageWithoutAnimation via imperative handle.
|
||||
*/
|
||||
import React from 'react';
|
||||
import { View, type ViewStyle } from 'react-native';
|
||||
@@ -11,16 +10,35 @@ interface PagerViewProps {
|
||||
style?: ViewStyle;
|
||||
initialPage?: number;
|
||||
scrollEnabled?: boolean;
|
||||
onPageSelected?: (e: any) => void;
|
||||
onPageSelected?: (e: { nativeEvent: { position: number } }) => void;
|
||||
onPageScrollStateChanged?: (e: any) => void;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
const PagerView = React.forwardRef<View, PagerViewProps>(
|
||||
({ children, style, initialPage = 0 }, ref) => {
|
||||
export interface PagerViewHandle {
|
||||
setPage: (page: number) => void;
|
||||
setPageWithoutAnimation: (page: number) => void;
|
||||
}
|
||||
|
||||
const PagerView = React.forwardRef<PagerViewHandle, PagerViewProps>(
|
||||
({ children, style, initialPage = 0, onPageSelected }, ref) => {
|
||||
const [currentPage, setCurrentPage] = React.useState(initialPage);
|
||||
const pages = React.Children.toArray(children);
|
||||
|
||||
React.useImperativeHandle(ref, () => ({
|
||||
setPage(page: number) {
|
||||
setCurrentPage(page);
|
||||
onPageSelected?.({ nativeEvent: { position: page } });
|
||||
},
|
||||
setPageWithoutAnimation(page: number) {
|
||||
setCurrentPage(page);
|
||||
onPageSelected?.({ nativeEvent: { position: page } });
|
||||
},
|
||||
}));
|
||||
|
||||
return (
|
||||
<View ref={ref} style={[{ flex: 1 }, style]}>
|
||||
{pages[initialPage] ?? pages[0] ?? null}
|
||||
<View style={[{ flex: 1 }, style]}>
|
||||
{pages[currentPage] ?? pages[0] ?? null}
|
||||
</View>
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user