kojow7
kojow7

Reputation: 11404

React-native JSON files being cached?

I am reading json files into a react-native app using require. For example:

myfiles.json:

const myfiles = {
    one: require('./files/one.json'),
    two: require('./files/two.json'),
    three: require('./files/three.json')
}
export myfiles

However, I have updated my JSON files and the updates are not showing in the IOS simulator. I have tried closing the simulator and running react-native run-ios but it is still showing the old data from the JSON files.

Are these being cached somewhere? If so, where? What do I have to do to see the updates?

Upvotes: 0

Views: 337

Answers (1)

Khanh Le Tran
Khanh Le Tran

Reputation: 900

I suggest these ways to reset emulator and clean iOS build if you use xcode:

  • To reset the iOS simulator and erase all simulator data go to menu and Hardware -> Erase All Content and Settings

enter image description here

  • To clean the iOS build press Option+Shift+Command+K or go to Xcode menu Product -> Clean Build Folder. This will only clean cache for your current target

enter image description here

** After all uninstall your app on emulator and reinstall.

Upvotes: 1

Related Questions