-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v3 Breaking Changes #90
Comments
🎉 This issue has been resolved in version 3.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I think the nextjs docs are out of date after the v3 upgrade: https://yet-another-react-lightbox.com/examples/nextjs Need to import them from Also would be nice for the example to have types. |
Please see #124. Both
You can find the link to TS version of the sandbox in the |
Also can you link the typescript file? I am looking through the sandbox and i cannot find it: I am making a slight change to the expected types (making alt, width, and height mandatory) because i this type error: But when I do this:
I get a type error with the renderProp... So kind of going in circles so an example would be nice. |
As you can see #124 was released in v3.6.0. So you should either upgrade to the latest version (there is no reason not to upgrade), or use
The link is in the comments in the |
Also, please feel free to open a separate issue or discussion as this topic is really unrelated to the scope of this ticket. |
v3 Breaking Changes
Release 3.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.
slides and index props can now be updated
Previously, the lightbox used to take a snapshot of the
slides
andindex
props when opening and ignoring any subsequent updates to these props. v3 adds an ability to update theslides
andindex
props.In most cases, you do not need to update these props manually, as the lightbox maintains its state internally. You may need to update the
index
prop when you modify or completely replace theslides
array. When theindex
property changes, the lightbox renders the specified slide without an animation effect. To navigate to a different slide with an animation effect, use the correspondingcontroller.ref
method.Please note that updating the
slides
array (or just changing the array reference) forces the lightbox to update itsstate based on the current
slides
andindex
values. You can safely use a non-stable array reference(i.e.,
slides={[...]}
orslides={items.map((item) => ({...}))}
) as long as the component holding the lightbox doesnot re-rerender while the lightbox is open. However, if your component may re-render, be sure to provide the
slides
prop as a stable array reference (i.e.,
const
in static scope, or wrapped withReact.useState
orReact.useMemo
).slide, slideHeader, slideFooter and slideContainer render functions props changed
Render functions now accept a single parameter with named props. Please use destructuring to access the required props.
v2:
v3:
view, click and zoom callbacks props changed
Callback functions now accept a single parameter with named props. Please use destructuring to access the required props.
v2:
v3:
animation easing settings moved to animation.easing
v2:
v3:
The lightbox is now using
ease-in-out
/ease-out
for swipe animation by default.ControllerContext no longer provides getLightboxProps, use useLightboxProps hook instead
The
useController
hook no longer provides thegetLightboxProps
function. Use theuseLightboxProps
hook instead.v2:
v3:
fullscreen prop is no longer a boolean
Fullscreen plugin now accepts
fullscreen
settings prop.v2:
v3:
render.buttonFullscreen render function props changed
Please see the latest plugin documentation.
render.buttonSlideshow render function props changed
Please see the latest plugin documentation.
render.buttonZoomIn and render.buttonZoomOut custom render functions were replaced with buttonZoom
If you'd like to render custom zoom-in / zoom-out control, please use
render.buttonZoom
render function. However, if you wish just to change the icons, you can still use therender.iconZoomIn
andrender.iconZoomOut
render functions.PluginMethods type was renamed to PluginProps
v2:
v3:
animationDuration prop is no longer available in the LightboxState
animationDuration
prop in theLightboxState
was removed in favor ofanimation.duration
Backdrop click and toolbar width events were removed
The following events were removed:
The text was updated successfully, but these errors were encountered: