Skip to content

Commit

Permalink
check whether stats.data is empty before accessing length
Browse files Browse the repository at this point in the history
  • Loading branch information
kangzj committed Jan 8, 2025
1 parent 0720d8c commit d2ad07f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion client/my-sites/stats/stats-post-summary/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class StatsPostSummary extends Component {
const selectedRecordIndex = chartData.findIndex(
( item ) => item.period === selectedRecord.period
);
if ( 'day' === this.state.period ) {
if ( 'day' === this.state.period && stats.data ) {
const maxPages = Math.ceil( stats.data.length / StatsPostSummary.MAX_RECORDS_PER_DAY );
disablePreviousArrow = this.state.page >= maxPages && selectedRecordIndex === 0;
disableNextArrow = 1 === this.state.page && selectedRecordIndex === chartData.length - 1;
Expand Down

0 comments on commit d2ad07f

Please sign in to comment.