From 21f94d75d419b47174fc3f16b0b4d617a8c8adc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hakan=20Ak=C4=B1n?= Date: Fri, 29 May 2026 14:10:52 +0100 Subject: [PATCH] fix: avoid loading legacy PdfView on Fabric path --- index.js | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/index.js b/index.js index 79994ba7..98cf5f19 100644 --- a/index.js +++ b/index.js @@ -21,14 +21,22 @@ import PdfViewNativeComponent, { Commands as PdfViewCommands, } from './fabric/RNPDFPdfNativeComponent'; import ReactNativeBlobUtil from 'react-native-blob-util' -import {ViewPropTypes} from 'deprecated-react-native-prop-types'; const SHA1 = require('crypto-js/sha1'); -import PdfView from './PdfView'; + +let PdfView; + +const getPdfView = () => { + if (!PdfView) { + const module = require('./PdfView'); + PdfView = module.default || module; + } + + return PdfView; +}; export default class Pdf extends Component { static propTypes = { - ...ViewPropTypes, source: PropTypes.oneOfType([ PropTypes.shape({ uri: PropTypes.string, @@ -454,17 +462,17 @@ export default class Pdf extends Component { path={this.state.path} onChange={this._onChange} /> - ):() + ):(React.createElement(getPdfView(), { + ...this.props, + style: [{backgroundColor: '#EEE',overflow: 'hidden'}, this.props.style], + path: this.state.path, + onLoadComplete: this.props.onLoadComplete, + onPageChanged: this.props.onPageChanged, + onError: this._onError, + onPageSingleTap: this.props.onPageSingleTap, + onScaleChanged: this.props.onScaleChanged, + onPressLink: this.props.onPressLink, + })) ) )} );