question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

forceCheck doesnt load items that are already in viewport

See original GitHub issue

Current implementation:

/**
*
* CoverPhoto
*
*/

import React from 'react';
import classnames from 'classnames/bind';
import DebugHelper from 'utils/debug';
import LazyLoad, { forceCheck } from 'react-lazyload';
import styles from './CoverPhoto.styl';

const cx = classnames.bind(styles);
const debug = new DebugHelper('components/CoverPhoto');

export class CoverPhoto extends React.Component {
  componentDidMount () {
    forceCheck();
  }

  render () {
// const CoverPhoto = (props) => {
    debug('render');
    const { props } = this;
    const className = cx(props.className, {
      coverPhoto: true,
      hasRatio: props.ratio,
      [`ratio-${props.ratio}`]: props.ratio,
    });
    const imgProps = {
      src: props.src,
      alt: props.alt,
    };

    return (
      <div className={className}>
        <LazyLoad
          height={props.height || 100}
          offset={300}
          once
        >
          <img
            {...imgProps}
            className={styles.photo}
            role="presentation"
          />
        </LazyLoad>
      </div>
    );
  }
}

export default CoverPhoto;

CoverPhoto is then used in other components, like a ProductCard:

productcard

Though forceCheck is called, the image is not loaded even though ProductCard is already inside the viewport.

By looking at the log, somehow componentDidMount is being called before render(). Is that becuase the component is not fully mounted till LazyLoad finish rendering? Any hint on how this can be?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:21

github_iconTop GitHub Comments

13reactions
constantxcommented, Apr 6, 2017

setTimeout(forceCheck, 1000) works 😉 I mistyped the function name

1reaction
jasonslyviacommented, Apr 7, 2017

Glad you work it out!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Facecheck Troubleshooting - Overwolf Support
This may occur when either: The app's auto launch setting is set to Off; The auto launch permission of the app is set...
Read more >
Facecheck doesn't work : r/Overwolf - Reddit
I really need some help because FaceCheck helps me spot good targets to easy kill(in terms of jgling and roaming) because I know...
Read more >
Troubleshooting - Facecheck - Medium
Close and re-open Facecheck after a few seconds. Loading takes forever. The team stats or in-game loading takes forever. This can happened when ......
Read more >
Facecheck League of Legends App Review December 2021
facecheck league of legends app review. This video is a personal review of the league of legends app FaceCheck powered by Overwolf.
Read more >
Facecheck is BACK! "C9 and Rogue Both Making it ... - YouTube
Facecheck is BACK! Join dGon, LS, and Dom as they discuss the group draw for League of Legends Worlds 2021 and make their...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found