igordanchenko / react-photo-album

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

v2 Breaking Changes #85

Closed igordanchenko closed 1 year ago

igordanchenko commented 1 year ago

v2 Breaking Changes

Release 2.0 comes with some minor breaking changes. Although the list is relatively long, the migration should be trivial for most users. Be sure to review the items that apply in your case.

onClick callback signature change

v1:

<PhotoAlbum
    onClick={(event, photo, index) => {
        // ...
    }}
    // ...
/>

v2:

<PhotoAlbum
    onClick={({event, photo, index}) => {
        // ...
    }}
    // ...
/>

SSR and defaultContainerWidth

v2 does not provide a default value for the defaultContainerWidth prop. If not defined, PhotoAlbum produces empty markup on the server and renders actual markup only on the client after hydration. If you prefer the markup to be generated on the server, you must explicitly set the defaultContainerWidth prop.

columnConstraints prop is no longer supported

v2 strictly adheres to the columns value when rendering columns or masonry layout. It renders empty columns when there aren't enough images to fill all columns, so the columnConstraints.minColumns prop is no longer relevant. However, if you prefer how things worked in v1, you can implement v1 behavior through the columns prop:

<PhotoAlbum
    layout="masonry"
    photos={photos}
    columns={Math.min(photos.length, 3)}
/>

resizeObserverProvider prop is no longer supported

v2 no longer supports custom resize observers, and only global ResizeObserver is used.

renderContainer prop no longer accepts React.forwardRef

v2 no longer accepts forwardRef-wrapped component in the renderContainer prop. You must pass the containerRef to the <div/> element when rendering custom container.

<PhotoAlbum
    renderContainer={({ containerRef, children }) => <div ref={containerRef}>{children}</div>}
    // ...
/>

renderContainer signature change

v2 no longer provides the layoutOptions parameter as part of the renderContainer render function parameters. layoutOptions parameter was replaced with layout.

viewportWidth is no longer provided in the layoutOptions

v2 no longer provides the viewportWidth value in the layoutOptions object.

containerWidth parameter in the componentsProps is now optional

<PhotoAlbum
    componentsProps={(containerWidth) => {
        if (containerWidth) {
            // ...
        } else {
            // 
        }
    }}
    // ...
/>

package bundle changes

type definitions changes

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 2.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: