jaredLunde/masonic

Queue does not exist when using useMasonry

wiktoriavh opened this issue · 2 comments

Describe the bug
The masonry is not loading always and if it does and I scroll down, I get an error thrown that queue does not exist and it points to useMasonry().

Steps To Reproduce

  1. open Codesandbox
  2. https://codesandbox.io/s/masonry-queue-issue-o27rw?file=/src/MasonryGrid.js
  3. If the masonry loaded, scroll down and the error might appear.

Here is a gif of it happening: https://imgur.com/a/xfFwR5h It's 30 seconds long.
Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
https://imgur.com/a/xfFwR5h
30-second long gif displaying the issues.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Vivaldi (Chromium)
  • Version: 3.4.1

Additional context
https://codesandbox.io/s/masonry-queue-issue-o27rw?file=/src/MasonryGrid.js
Codesandbox example.

The usage of useInfiniteLoader on line 50 of the codesandbox is violating the rules of hooks:

  const checkLength = () => {
    if (items.length >= list.length) {
      console.log(items.length, list.length);
      return;
    } else {
      return useInfiniteLoader( // FIXME: this hook is being called conditionally

You are right. @jonbri