0

I want to implement a game where players get clues to guess a pre-determined word. I have the clues and correct answers in a JSON file. Now, I want to create a user interface using React. However, I am unable to figure out how to make my data available to the React components. What would be a good way to do this?

I created a JSON file and included it as a script in html as mentioned in this answer, but I am still not able to accessible through the React components. I am a complete beginner at web development, so I would really appreciate it if you could explain the underlying concepts.

Abhilash
  • 85
  • 3
  • 11

1 Answers1

2

Are you using Create React App? If so, this should be as simple as placing the JSON file with the proper syntax in the src folder. Then you can use a simple default import statement using a relative path.

import NameForImportedObject from './filename.json';

Jorge Navarro
  • 574
  • 5
  • 2