I have this variable
const routes = [{data : 'Home' , icon : 'home' , keep:true , txt:'Home'} , {data : 'NECard' , icon : 'card' , keep:true , txt:'Your Card'} , {data : 'Notifications' , icon : 'notifications' , color : '#EB4D4B' , count : 27 , keep:true , txt:'Notifications'} , {data : 'Requests' , icon : 'contacts' , color : '#0097E6' , count : 8 , keep:true , txt:'Requests'} , {data : 'Saved' , icon : 'bookmark' , color : '#FBC531' , count : 51 , keep:true , txt:'Saved'} , {data : 'Logout' , icon : 'ios-exit' , keep:true , txt:'Logout'}];
I set the state in the constructor
this.state = {routes : routes};
also after mounting the component I run this
componentDidMount()
{
this.fetchNotReadedNotis();
}
the last step
async fetchNotReadedNotis()
{
this.state.routes[2].count = 392;
this.forceUpdate();
}
using setState is also not working
async fetchNotReadedNotis()
{
var rts = this.state.routes;
rts[2].count = 392;
this.setState({routes:rts});
}
the expected is to set the routes[2] count property to 392
but no changes at all , it still 27
is there something wrong with my codes?