MCPcopy Index your code
hub / github.com/wonday/react-native-pdf / componentDidMount

Function componentDidMount

PdfView.js:95–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93 }
94
95 componentDidMount() {
96 this._mounted = true;
97 PdfManager.loadFile(this.props.path, this.props.password)
98 .then((pdfInfo) => {
99 if (this._mounted) {
100 const fileNo = pdfInfo[0];
101 const numberOfPages = pdfInfo[1];
102 const width = pdfInfo[2];
103 const height = pdfInfo[3];
104 const pageAspectRatio = height === 0 ? 1 : width / height;
105
106 this.setState({
107 pdfLoaded: true,
108 fileNo,
109 numberOfPages,
110 pageAspectRate: pageAspectRatio,
111 pdfPageSize: {width, height},
112 centerContent: numberOfPages > 1 ? false : true
113 });
114 if (this.props.onLoadComplete) {
115 this.props.onLoadComplete(numberOfPages, this.props.path, {width, height});
116 }
117 }
118
119 })
120 .catch((error) => {
121 this.props.onError(error);
122 });
123
124 clearTimeout(this._scrollTimer);
125 this._scrollTimer = setTimeout(() => {
126 if (this._flatList) {
127 this._flatList.scrollToIndex({animated: false, index: this.props.page < 1 ? 0 : this.props.page - 1});
128 }
129 }, 200);
130 }
131
132 componentDidUpdate(prevProps) {
133

Callers

nothing calls this directly

Calls 2

loadFileMethod · 0.80
onErrorMethod · 0.80

Tested by

no test coverage detected