igordanchenko / react-photo-album

Responsive photo gallery component for React
https://react-photo-album.com
MIT License
567 stars 35 forks source link

PhotoAlbum component has a null images #116

Closed jones-semicolon closed 1 year ago

jones-semicolon commented 1 year ago

Describe the bug

I am new to react and i found this library useful however when i tried to return only the PhotoAlbum component it doesnt have any images so i tried to use renderContainer props to see if it really stores the images that i provided and it is still null. The only solution to get it work is to enclosed it with a div element and adding a sibling element and also if the parent element of the PhotoAlbum component is a styled-component then it will not work, i actually dont know why.

Expected behavior

Screenshot_2023-07-03-01-10-35-06_d073e7407281f7a2d9df7c9f755e6603

I want it to be inside the styled-component

How to reproduce

render() {
    const { photos } = this.state;
    return (
      <Content>
        <h4>Portfolio</h4>
        <PhotoAlbum layout="rows" photos={photos} />
      </Content>
    )
/
  }

The above code only returns the container of PhotoAlbum component

render() {
    const { photos } = this.state;
    return (
      <>
        <h4>Portfolio</h4> //always add sibling to make it work
        <PhotoAlbum layout="rows" photos={photos} />
      </>
    )
  }

The above code will work

Screenshots / Logs

No response

Additional context

I now found the issue, if I set the parent element to flex it will reproduce the bug

igordanchenko commented 1 year ago

Based on the attached screenshot, you want to use either display: block or display: flex; flex-direction: column on the parent element. If you are still experiencing this issue, please provide a complete example demonstrating the issue.