alanmoraales / use-justified-layout

Flickr's justified-layout in a React hook.
https://www.npmjs.com/package/use-justified-layout
1 stars 0 forks source link

const [ layout ] = useJustifiedLayout( ... ) caused infinite rerender loop #1

Open yelnyafacee opened 1 year ago

yelnyafacee commented 1 year ago

Hi, I tried using this package:

  // Declare & Set Layout Config
  const layoutConfig2 = {
    containerPadding: 0,
    containerWidth: containerWidth,
    boxSpacing: {
      horizontal: 10,
      vertical: 10
    },
    // forceAspectRatio: 1
  };

  const [ layout ] = useJustifiedLayout({
      layoutInput: JSON.parse(props.imageSizesJSON),
      configuration: layoutConfig2,
      dependencies: []
  })

  console.log('useJustifiedLayout > layout: ' + JSON.stringify(layout, null, 2));

and it is causing infinite re-render loop

alanmoraales commented 1 year ago

Hey @yelnyafacee were you able to find the problem? I think it's because of the JSON.parse(). I'm sorry about not noticing your issue before.