Skip to content

Commit

Permalink
fix(fsproductindex): Fix commerceData errors
Browse files Browse the repository at this point in the history
- Add safety check that state exists
- Use proper commercedata variable when requesting reviews
- Remove unused state variable
  • Loading branch information
nathan-sankbeil authored and bweissbart committed Aug 1, 2018
1 parent a8f0128 commit f483bd8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/fsproductindex/src/components/ProductIndexProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export interface WithProductIndexState<
* Indicates that we've received new commerce data but have not yet requested and merged reviews
* for that data
*/
commerceDataDirty: boolean;
reviewsData?: ReviewTypes.ReviewSummary[];
}

Expand Down Expand Up @@ -159,7 +158,7 @@ function withProductIndexData<
return (
<WrappedComponent
{...props}
commerceData={this.state.commerceData || this.props.commerceData}
commerceData={(this.state && this.state.commerceData) || this.props.commerceData}
reviewsData={(this.state && this.state.reviewsData)}
/>
);
Expand All @@ -170,10 +169,10 @@ function withProductIndexData<
*/
private requestReviews = async (): Promise<void> => {
const {
commerceData,
commerceToReviewMap = 'id',
reviewDataSource
} = this.props;
const { commerceData } = this.state;
} = this.props as ResultProps;

if (
!reviewDataSource ||
Expand Down Expand Up @@ -211,8 +210,7 @@ function withProductIndexData<

this.setState({
reviewsData: summaries,
commerceData: updatedCommerceData,
commerceDataDirty: false
commerceData: updatedCommerceData
});
}
}
Expand Down

0 comments on commit f483bd8

Please sign in to comment.