Hi i have this code that fetch and returns json data from file config.json
text.js
class Text extends React.Component {
constructor(props){
super(props)
this.state = {
datat: [],
};
}
componentDidMount(){
fetch('/config.json')
.then(response => response.json())
.then((datao) =>{
this.setState({
datat: (JSON.parse(JSON.stringify(datao)))
})
});
}
render(){
const datatorender = this.state.datat;
return ( Object.keys(datatorender).map(key =>{if(key==this.props.value){return datatorender[this.props.value]}}))
}}
and how i call it in home is like : home.js
<Text value="SITENAME">
so i want to call it like this :
{text.SITENAME} instead of fist one
how can i do that ?
and this is the json file :
{
"SITENAME": "site name",
"SITE_DESCRIPTION":"desc"
}