Below is the initial state which is assigned
state = { movie : null, actors : null, directors : [], loading : false } Below is the set state which i set and at the end to set state as put in comment when it is set and not set. I'm not able to access the this.state outside.
this.setState({movie:result},() => { //then fetch the actors const endpoint= `${API_URL}movie/${this.props.match.params.movieId}/credits?api_key=${API_KEY}`; fetch(endpoint) .then(result => result.json()) .then(result=>{ const directors =result.crew.filter((member)=> member.job==='Director' ); this.setState({ actors : result.cast, directors, loading : false }) console.log(this.state); //here value is coming }) })console.log(this.state); //here value is not coming How to get this.state value with updated info?
render() { //removed code below mull div return ( <div className="rmdb-movie"> {this.state.movie ? <div> <Navigation movie={this.props.location.movieName}/> </div> : null } </div> ) }