jsonreact-nativeofflineapps

How do I fetch name.json file with reactNative locally?


For Android application!

Let say in our project folder we create a file name.json.

Now I want to use the name.json file for displaying some data in our application!


Solution

  • You can import the file like below:

    import nameData from 'yourPathToFile/name';
    

    Now you can use it like:

    //IF name.json have an array
    nameData[0].name; // example
    //If name.json have object
    nameData.name; //example