I'm working on a React Native application that involves choosing words from a list of 200,000. I already have this list of words, but I'm having trouble putting it into my application. At first, I wanted to put them in a separate file and read them into an array, but React Native does not have access to the fs node module. I tried copying and pasting them in directly, but this is messy and cumbersome. Are there any other ways that this can be done? Any help would be appreciated!
You can simply Store the data in json
in a seperate file, And then import
it using the import
statement.
Here is an example.
data.json file
{
"name": "saroj",
"age": 180
}
app.js
import json from "./data.json";
function App() {
console.log(json);
return <View style={styles.app}></View>;
}
the output is :
{name: "saroj", age: 180}
According to question
you can store the list of over 200,000 words in an array in a json file like wise:
{
"wordList": [
"word1",
"word2",
"word3",
..
...
....
"word200000"
]
}
thank you.