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 ?
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.
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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With