Skip to content

Commit

Permalink
Removed useInView
Browse files Browse the repository at this point in the history
  • Loading branch information
iaron committed Feb 6, 2020
1 parent 23e3962 commit c2f1500
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Removed
- `useInView` on `ShelfItem` since this logic was moved to the `product-summary` now.

## [1.35.3] - 2020-02-06
### Fixed
Expand Down
20 changes: 1 addition & 19 deletions react/components/ShelfItem.js
@@ -1,12 +1,9 @@
import React, { useMemo, useCallback, useEffect } from 'react'
import React, { useMemo, useCallback } from 'react'
import { assocPath } from 'ramda'
import { useInView } from 'react-intersection-observer'
import { ProductListContext } from 'vtex.product-list-context'
import ProductSummary from 'vtex.product-summary/ProductSummaryCustom'
import { ExtensionPoint } from 'vtex.render-runtime'
import { usePixel } from 'vtex.pixel-manager/PixelContext'

const { useProductListDispatch } = ProductListContext
/**
* ShelfItem Component. Normalizes the item received in the props
* to adapt to the extension point prop.
Expand All @@ -28,24 +25,9 @@ const ShelfItem = ({ item, summary }) => {
})
}, [product, push])

const [inViewRef, inView] = useInView({
// Triggers the event when the element is 75% visible
threshold: 0.75,
triggerOnce: true,
})

const dispatch = useProductListDispatch()

useEffect(() => {
if (inView) {
dispatch({ type: 'SEND_IMPRESSION', args: { product: product } })
}
}, [dispatch, inView, product])

return (
<ExtensionPoint
id="product-summary"
containerRef={inViewRef}
product={product}
actionOnClick={pushPixelProductClick}
{...newSummary}
Expand Down

0 comments on commit c2f1500

Please sign in to comment.