In an attempt to incorporate react context into one of my projects, I'm facing a challenge. Specifically, I want to showcase the state information once the state is modified, i.e., when the confirmFavourites function is invoked.
export class AppProvider extends React.Component {
constructor(props){
super(props)
this.state = {
page: 'dashboard',
...this.savedSettings(),
setPage: this.setPage,
confirmFavorites: this.confirmFavorites
}
}
confirmFavorites = () => {
this.setState({
firstVisit: false,
page: 'dashboard'
})
localStorage.setItem('cryptoDash', JSON.stringify({
'test': 'hello'
}))
console.log('Hello1 -', this.state)
}
Upon checking the logged state information, I notice that the firstVisit variable is not being displayed as expected.