Issue
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.
Solution
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';
Answered By - Jorge Navarro Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.