Open kamleshchandnani opened 7 years ago
Try this:
let data = await FileSystem.writeToFile('./productsData', JSON.stringify(productsData.Data))
@benwixen I can't Since I am using this inside my saga generators. So await can't be used inside generator.
Hi, I'm not very familiar with sagas or yields, and not entirely sure if the yield-keyword is the issue. Can you use promises?
let promise = FileSystem.writeToFile('./productsData', JSON.stringify(productsData.Data));
promise.then(data => {
// do your thing with 'data' here
});
@benwixen BTW where this data is stored physically? I am having data ~15mb
It's stored on the persistent disk of the device. The exact location depends on operating system, and storage class (the default class is storage.backedUp):
https://github.com/benwixen/react-native-filesystem/blob/master/docs/reference.md#filesystemstorage
Btw, if you're downloading this data, it will be more efficient to use a file download-library. If you first pass the data through the javascript side, it will have to stay in memory until it's written, and then be passed over the React Native bridge (not very performant).
yield is not the issue. because yields gives you the flexibilities of await. So the issue is something else. RNFileSystem is not getting initialized from react-native. RNFileSystem is undefined and hence the error RNFileSystem.writeToFile (cannot read writeToFile of undefined)
I'm sorry, but it's hard for me to say exactly what your problem might be.
If you can make a minimal project that reproduces the issue, and share it through Github or other means, I will try to pinpoint / fix the issue.
Package is also imported
import FileSystem from 'react-native-filesystem'
Rebuilt after installng react-native-filesystem. Still no luck! Can somebody help