0

I have a json file in my react-native project how do I access it in one of my components?

The structure of the project

It has index.js and App on the same level Then it has components on the next level In components it has databases and Main.js In databases it has database.json

I want to use information held in database.json inside Main.js, I can also change the file structure not sure what is the best way to do this.

Thanks for any help

1 Answer 1

2

You can just require your JSON file like any regular javascript file.

let data = require('../../database.json')
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.