I am trying to open a local JSON file and have the information displayed on my app.
The code seems to run but the JSON information doesn't display. How do I get the JSON information, name & age fields to display?
JSON file:
[
{
"name": "George",
"age": "25"
},
{
"name": "Sarah",
"age": "42"
}
]
App.js:
import * as myfile from './myfile.json'
const name = myfile.name;
const age = myfile.name;
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>This is name: {name} This is age: {age}
</Text>
</View>
);
}
}