![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
react-native-doc-viewer
Advanced tools
React Native Native Module Bridge Quicklock Document Viewer for IOS + Android supports pdf, png, jpg, xls, ppt, doc, docx, pptx, xlx + Video Player mp4 supported
A React Native bridge module: Document Viewer for files (pdf, png, jpg, xls, doc, ppt, xlsx, docx, pptx etc.)
Changelog:
2.7.2 - Progress Download Feedback in example and Done Button Callback IOS
2.7.1 - Fix Progress IOS Download
2.6.9 - Progress IOS DOWNLOAD Document Callback in Native Code
2.6.0 - Android Openbase64
2.5.2 - OpenDocAndroid
2.5.1 - Cleanings
2.5.0 - Update Project for React Native 0.50.3
$ npm install react-native-doc-viewer --save
$ react-native link react-native-doc-viewer
In XCode, in the project navigator, right click Libraries
➜ Add Files to [your project's name]
Go to node_modules
➜ react-native-doc-viewer
and add RNReactNativeDocViewer.xcodeproj
In XCode, in the project navigator, select your project. Add libRNReactNativeDocViewer.a
to your project's Build Phases
➜ Link Binary With Libraries
Linked Frameworks and Libraries must have this 2 Libraries (AssetsLibrary.framework & QuickLock.framework). When not you have to add them.
When you Show http Links don't forget to set APP Transport Security Settings -> Allow Arbitrary Loads to YES
Cmd+R
)<android/app/src/main/java/[...]/MainActivity.java
import com.reactlibrary.RNReactNativeDocViewerPackage;
to the imports at the top of the filenew RNReactNativeDocViewerPackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
include ':react-native-doc-viewer'
project(':react-native-doc-viewer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-doc-viewer/android')
android/app/build.gradle
:
compile project(':react-native-doc-viewer')
RNReactNativeDocViewer.sln
in node_modules/react-native-react-native-doc-viewer/windows/RNReactNativeDocViewer.sln
folder to their solution, reference from their app.MainPage.cs
appusing Com.Reactlibrary.RNReactNativeDocViewer;
to the usings at the top of the filenew RNReactNativeDocViewerPackage()
to the List<IReactPackage>
returned by the Packages
methodresource | description |
---|---|
DoneButtonEvent | return true |
RNDownloaderProgress | return Progress Float |
resource | description |
---|---|
openDoc | {url:String,fileNameOptional:String (optional)} |
openDocb64 | {url:String,fileName:String,fileType:String } |
openDocBinaryinUrl | {url:String,fileName:String,fileType:String } |
resource | description |
---|---|
openDoc | {url:String,fileName:String, cache:boolean} |
openDocb64 | {url:String,fileName:String,fileType:String, cache:boolean } |
openDocBinaryinUrl | not implemented yet |
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Platform,
Button,
Alert,
ActivityIndicator,
NativeAppEventEmitter,
DeviceEventEmitter,
NativeModules,
NativeEventEmitter,
TouchableHighlight
} from 'react-native';
import OpenFile from 'react-native-doc-viewer';
var RNFS = require('react-native-fs');
var SavePath = Platform.OS === 'ios' ? RNFS.MainBundlePath : RNFS.DocumentDirectoryPath;
export default class DocumentViewerExample extends Component {
constructor(props) {
super(props);
this.state = {
animating: false,
progress: "",
donebuttonclicked: false,
}
this.eventEmitter = new NativeEventEmitter(NativeModules.RNReactNativeDocViewer);
this.eventEmitter.addListener('DoneButtonEvent', (data) => {
/*
*Done Button Clicked
* return true
*/
console.log(data.close);
this.setState({donebuttonclicked: data.close});
})
this.didPressToObjcButton = this.didPressToObjcButton.bind(this);
}
componentDidMount(){
// download progress
this.eventEmitter.addListener(
'RNDownloaderProgress',
(Event) => {
console.log("Progress - Download "+Event.progress + " %")
this.setState({progress: Event.progress + " %"});
}
);
}
componentWillUnmount (){
this.eventEmitter.removeListener();
}
/*
* Handle WWW File Method
* fileType Default == "" you can use it, to set the File Extension (pdf,doc,xls,ppt etc) when in the Url the File Extension is missing.
*/
handlePress = () => {
if(Platform.OS === 'ios'){
//IOS
OpenFile.openDoc([{
url:"https://www.cmu.edu/blackboard/files/evaluate/tests-example.xls",
fileNameOptional:"sample-test"
}], (error, url) => {
if (error) {
console.error(error);
} else {
console.log(url)
}
})
}else{
//Android
OpenFile.openDoc([{
url:"http://mail.hartl-haus.at/uploads/tx_hhhouses/htf13_classic153s(3_giebel_haus).jpg", // Local "file://" + filepath
fileName:"sample",
cache:false,
fileType:"jpg"
}], (error, url) => {
if (error) {
console.error(error);
} else {
console.log(url)
}
})
}
}
/*
* Binary in URL
* Binary String in Url
* fileType Default == "" you can use it, to set the File Extension (pdf,doc,xls,ppt etc) when in the Url you dont have an File Extensions
*/
handlePressBinaryinUrl = () => {
if(Platform.OS === 'ios'){
//IOS
OpenFile.openDocBinaryinUrl([{
url:"https://storage.googleapis.com/need-sure/example",
fileName:"sample",
fileType:"xml"
}], (error, url) => {
if (error) {
console.error(error);
} else {
console.log(url)
}
})
}else{
//Android
Alert.alert("Coming soon for Android")
}
}
/*
* Handle local File Method
* fileType Default == "" you can use it, to set the File Extension (pdf,doc,xls,ppt etc) when in the Url you dont have an File Extensions
*/
handlePressLocalFile = () => {
if(Platform.OS === 'ios'){
OpenFile.openDoc([{
url:SavePath+"filename.pdf",
fileNameOptional:"sample"
}], (error, url) => {
if (error) {
console.error(error);
} else {
console.log(url)
}
})
}else{
//Android
OpenFile.openDoc([{
url:SavePath+"filename.pdf",
fileName:"sample",
cache:true /*Use Cache Folder Android*/
}], (error, url) => {
if (error) {
console.error(error);
} else {
console.log(url)
}
})
}
}
/*
* Base64String
* put only the base64 String without data:application/octet-stream;base64
* fileType Default == "" you can use it, to set the File Extension (pdf,doc,xls,ppt etc) when in the Url you dont have an File Extensions
*/
handlePressb64 = () => {
if(Platform.OS === 'ios'){
OpenFile.openDocb64([{
base64:"{BASE64String}"
fileName:"sample",
fileType:"png"
}], (error, url) => {
if (error) {
console.error(error);
} else {
console.log(url)
}
})
}else{
//Android
OpenFile.openDocb64([{
base64:"{BASE64String}"
fileName:"sample",
fileType:"png",
cache:true /*Use Cache Folder Android*/
}], (error, url) => {
if (error) {
console.error(error);
} else {
console.log(url)
}
})
}
/*
* Video File
*/
handlePressVideo = () => {
if(Platform.OS === 'ios'){
OpenFile.playMovie(video, (error, url) => {
if (error) {
console.error(error);
} else {
console.log(url)
}
})
}else{
Alert.alert("Android coming soon");
}
}
<Button
onPress={this.handlePress.bind(this)}
title="Press Me Open Doc Url"
accessibilityLabel="See a Document"
/>
<Button
onPress={this.handlePressBinaryinUrl.bind(this)}
title="Press Me Open BinaryinUrl"
accessibilityLabel="See a Document"
/>
<Button
onPress={this.handlePressb64.bind(this)}
title="Press Me Open Base64 String"
accessibilityLabel="See a Document"
/>
<Button
onPress={()=>this.handlePressVideo("http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4")}
title="Press Me Open Video"
accessibilityLabel="See a Document"
/>
}
Copyright (c) 2017-present, Philipp Hecht philipp.hecht@icloud.com
If this project help you reduce time to develop, you can give me a cup of coffee :)
FAQs
React Native Native Module Bridge Quicklock Document Viewer for IOS + Android supports pdf, png, jpg, xls, ppt, doc, docx, pptx, xlx + Video Player mp4 supported
The npm package react-native-doc-viewer receives a total of 105 weekly downloads. As such, react-native-doc-viewer popularity was classified as not popular.
We found that react-native-doc-viewer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.