componentDidMount() {
fetch(this.ApiURL + '/tv/dailyTV?location=' + localStorage.getItem('location'))
.then(res => res.json())
.then(data => {
this.setState({
companyname : data.static.companyname,
companymission : data.static.companymission,
videocount : data.static.videocount,
companyasset : data.static.companyasset
})
})
}
I want to fetch a data in my react application using a data from local storage. But component render before localstorage read the value so localStorage.getItem('location') return null.