scwebd
6/22/2018 - 2:48 AM

Render Movie React Method

...if you don't want to use a ternary directly inside the JSX, you could create a method outside the render and call it within your JSX curly brackets as {this.renderMovie}.

renderMovie = () => {
  if (this.state.result.Title) {
    return (
      <MovieDetail
        src={this.state.result.Poster}
        director={this.state.result.Director}
        genre={this.state.result.Genre}
        released={this.state.result.Released}
      />
    );
  } else {
    return <h3>No Results to Display</h3>;
  }
};