I have data.json file in my react app and I would like to use in my home.js file which have currently internally json values.
Is there any way to call data.json file into my this.state constructor.
class Home extends Component {
constructor ()
{
super();
this.state={
data:[
{
rank:1,
name:'Name one',
agency:'agency one',
},
{
rank:2,
name:'Name Two',
agency:'agency two',
},
{
rank:3,
name:'Name Three',
agency:'agency three',
}
]
}
}
render() {
return (
<div>
{
this.state.data.map((value) =>
<div>
<span>{value.rank}</span>
<span>{value.name}</span>
<span>{value.agency}</span>
</div>
)
}
</div>
);
}
}
export default Home;