Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any alternative available for react-native-fs library in React native?

I am reading large json files in React Native code but its giving me unacceptable performance hit. This performance problem for large files is also mentioned in their documentation.

Is there any alternate available which can help me to read files from document directory without hitting performance ?

like image 233
Sohail Mohabbat Ali Avatar asked May 20 '16 13:05

Sohail Mohabbat Ali


People also ask

Can you use fs in react native?

This is where react-native-fs comes in. It is an easy-to-use library that lets developers read and write files and folders to the host device.

How do you use fs readFile in react JS?

import React from 'react'; const fs = require('fs') const ToolTipTextMod = (props) => { let txt = null; fs. readFile('../../components/ToolTip/ToolTipText. txt',(err, data) => {console. log(data)}) return( <p>{txt},{props.


2 Answers

Right now for reading file it seems like react-native-fs is the only library available. It works fine with small files but in case of large file you may face a huge performance hit. For better performance write native module to access files and you'll feel fair amount of performance enhancement. In this way if you're supporting both iOS and Android you have to write code in Java and objective-c as well.

like image 147
Sohail Mohabbat Ali Avatar answered Oct 05 '22 06:10

Sohail Mohabbat Ali


react-native-fetch-blob purports to address this with readStream, and the react-native-fs maintainers consider fetch-blob to be the better library anymore (name not withstanding).

like image 37
outofculture Avatar answered Oct 05 '22 07:10

outofculture