import React from 'react'; import ReactDOM from 'react-dom'; import {formatPrice} from '../lib/helpers'; export default class Listings extends React.Component { constructor(props) { super(props); this.handleScroll = (e) => { const node = e.target; const offset = node.scrollHeight - node.scrollTop - node.clientHeight; //console.log('-----------------'); //console.log('node.scrollHeight', node.scrollHeight); //console.log('node.parentNode.scrollTop', node.scrollTop); //console.log('node.parentNode.clientHeight', node.clientHeight); console.log('scrolling', node.scrollTop, node.scrollHeight, offset); if (offset < 50) { console.log('load more'); this.removeScrollListener(); this.props.dispatch({type: 'LOAD_MORE_LISTINGS'}); } } } onListingClick(id) { this.props.dispatch({ type: 'VIEW_LISTING_DETAILS', action: { id } }); } onMouseEnter (id) { this.props.dispatch({ type: 'ON_LISTING_MOUSE_OVER', action: { id } }); } componentDidUpdate (prevProps) { console.log('RECEIVING PROPS: ', prevProps, 'new are', this.props); //setTimeout(() => { //this.attachScrollListener(); //}, 1000); if (this.props.loadingMore != null) { if (!this.props.loadingMore && prevProps.loadingMore) { this.attachScrollListener(); console.log('ATTACHING AGAIN', this); } } } renderListings () { const {listings = (new Map())} = this.props; if (listings.size === 0) { return (