React Image Grid Gallery v2 Release
React Image Grid Gallery version 2 is out! 🥳
Let’s discuss the highlights.
Breaking Changes
Section titled “Breaking Changes”This release comes with two breaking changes.
- Replace default
importwith namedimport. This change provides better compatibility with Node and Babel-like tools. - Rename
imgArrayprop toimagesInfoArray.
Other Changes
Section titled “Other Changes”- Change compiler from Babel to TypeScript.
- Remove Babel dependency.
- Replace
uniqiddependency withcrypto.randomUUID. - Convert all configuration files to TypeScript.
- Replace external CSS with inline styling.
How to Update the React Image Grid Gallery Package
Section titled “How to Update the React Image Grid Gallery Package”Here are the steps required to upgrade to the latest version:
-
Install the latest version
Terminal npm install react-image-grid-gallery@latestAlternatively, you can use Yarn or pnpm like so:
Yarn Installation yarn upgrade react-image-grid-gallery --latestPNPM Installation pnpm update react-image-grid-gallery --latest -
Update the package’s
importsyntaxReplace the package’s default
importstatement with the namedimportsyntax like so:import ImageGallery from "react-image-grid-gallery";import { ImageGallery } from "react-image-grid-gallery"; -
Update the package’s props
Update the required prop’s name as follows:
<ImageGalleryimgArray={imagesArray}imagesInfoArray={imagesArray}columnWidth={230}gapSize={24}/>
Note for Docusaurus Users
Section titled “Note for Docusaurus Users”Wrap the ImageGallery component in <BrowserOnly> if you get a ReferenceError: crypto is not defined error during your build step.
Example:
function YourComponent() { return ( <BrowserOnly fallback={<div>Loading...</div>}> {() => { const ImageGallery = require("react-image-grid-gallery").ImageGallery; return ( <ImageGallery imagesInfoArray={imagesArray} columnWidth={230} gapSize={24} /> ); }} </BrowserOnly> );}The <BrowserOnly> component tells Docusaurus to render the ImageGallery library only in the browser.
How to Use the React Image Grid Gallery Package
Section titled “How to Use the React Image Grid Gallery Package”See the complete project-based guide to learn how to add the ImageGallery package to your React applications. You can use the library with Vite, NextJS, Remix, or any other React app.