Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/recommend-react/src/FrequentlyBoughtTogether.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const UncontrolledFrequentlyBoughtTogether = createFrequentlyBoughtTogetherCompo

export type UseFrequentlyBoughtTogetherProps<TObject> = OptionalRecommendClient<
GetFrequentlyBoughtTogetherProps<TObject>
>;
> & { enabled?: boolean };

export type FrequentlyBoughtTogetherProps<
TObject
Expand Down
2 changes: 1 addition & 1 deletion packages/recommend-react/src/RelatedProducts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const UncontrolledRelatedProducts = createRelatedProductsComponent({

export type UseRelatedProductsProps<TObject> = OptionalRecommendClient<
GetRelatedProductsProps<TObject>
>;
> & { enabled?: boolean };

export type RelatedProductsProps<TObject> = UseRelatedProductsProps<TObject> &
Omit<
Expand Down
2 changes: 1 addition & 1 deletion packages/recommend-react/src/TrendingFacets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const UncontrolledTrendingFacets = createTrendingFacetsComponent({
Fragment,
});

export type UseTrendingFacetsProps = OptionalRecommendClient<GetTrendingFacetsProps>;
export type UseTrendingFacetsProps = OptionalRecommendClient<GetTrendingFacetsProps> & { enabled?: boolean };

export type TrendingFacetsProps = UseTrendingFacetsProps &
Omit<
Expand Down
2 changes: 1 addition & 1 deletion packages/recommend-react/src/TrendingItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const UncontrolledTrendingItems = createTrendingItemsComponent({

export type UseTrendingItemsProps<TObject> = OptionalRecommendClient<
GetTrendingItemsProps<TObject>
>;
> & { enabled?: boolean };

export type TrendingItemsProps<TObject> = UseTrendingItemsProps<TObject> &
Omit<
Expand Down
6 changes: 6 additions & 0 deletions packages/recommend-react/src/useFrequentlyBoughtTogether.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useStableValue } from './useStableValue';
import { useStatus } from './useStatus';

export function useFrequentlyBoughtTogether<TObject>({
enabled = true,
indexName,
maxRecommendations,
objectIDs: userObjectIDs,
Expand Down Expand Up @@ -40,6 +41,10 @@ export function useFrequentlyBoughtTogether<TObject>({
}, [userTransformItems]);

useEffect(() => {
if (!enabled) {
return;
}

const param = {
indexName,
maxRecommendations,
Expand Down Expand Up @@ -92,6 +97,7 @@ export function useFrequentlyBoughtTogether<TObject>({
});
return () => {};
}, [
enabled,
indexName,
maxRecommendations,
objectIDs,
Expand Down
10 changes: 9 additions & 1 deletion packages/recommend-react/src/useRecommendations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ import { useAlgoliaAgent } from './useAlgoliaAgent';
import { useStableValue } from './useStableValue';
import { useStatus } from './useStatus';

export type UseRecommendationsProps<TObject> = GetRecommendationsProps<TObject>;
export type UseRecommendationsProps<
TObject
> = GetRecommendationsProps<TObject> & { enabled?: boolean };

export function useRecommendations<TObject>({
enabled = true,
fallbackParameters: userFallbackParameters,
indexName,
maxRecommendations,
Expand All @@ -38,6 +41,10 @@ export function useRecommendations<TObject>({
}, [userTransformItems]);

useEffect(() => {
if (!enabled) {
return;
}

setStatus('loading');
getRecommendations({
fallbackParameters,
Expand All @@ -54,6 +61,7 @@ export function useRecommendations<TObject>({
setStatus('idle');
});
}, [
enabled,
fallbackParameters,
indexName,
maxRecommendations,
Expand Down
6 changes: 6 additions & 0 deletions packages/recommend-react/src/useRelatedProducts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useStableValue } from './useStableValue';
import { useStatus } from './useStatus';

export function useRelatedProducts<TObject>({
enabled = true,
fallbackParameters: userFallbackParameters,
indexName,
maxRecommendations,
Expand Down Expand Up @@ -42,6 +43,10 @@ export function useRelatedProducts<TObject>({
}, [userTransformItems]);

useEffect(() => {
if (!enabled) {
return;
}

const param = {
fallbackParameters,
indexName,
Expand Down Expand Up @@ -97,6 +102,7 @@ export function useRelatedProducts<TObject>({
return () => {};
}, [
client,
enabled,
fallbackParameters,
hasProvider,
indexName,
Expand Down
6 changes: 6 additions & 0 deletions packages/recommend-react/src/useTrendingFacets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useAlgoliaAgent } from './useAlgoliaAgent';
import { useStatus } from './useStatus';

export function useTrendingFacets({
enabled = true,
indexName,
maxRecommendations,
recommendClient,
Expand All @@ -37,6 +38,10 @@ export function useTrendingFacets({
}, [userTransformItems]);

useEffect(() => {
if (!enabled) {
return;
}

const param = {
model: 'trending-facets' as TrendingModel,
indexName,
Expand Down Expand Up @@ -84,6 +89,7 @@ export function useTrendingFacets({
});
return () => {};
}, [
enabled,
indexName,
maxRecommendations,
client,
Expand Down
6 changes: 6 additions & 0 deletions packages/recommend-react/src/useTrendingItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useStableValue } from './useStableValue';
import { useStatus } from './useStatus';

export function useTrendingItems<TObject>({
enabled = true,
fallbackParameters: userFallbackParameters,
indexName,
maxRecommendations,
Expand Down Expand Up @@ -42,6 +43,10 @@ export function useTrendingItems<TObject>({
}, [userTransformItems]);

useEffect(() => {
if (!enabled) {
return;
}

const param: BatchQuery<TObject> = {
model: 'trending-items',
fallbackParameters,
Expand Down Expand Up @@ -88,6 +93,7 @@ export function useTrendingItems<TObject>({
});
return () => {};
}, [
enabled,
fallbackParameters,
indexName,
maxRecommendations,
Expand Down