Skip to content

How can I pass props to my custom plugin #360

Answered by igordanchenko
BabkinAV asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there!

Here is how you can add TypeScript type definitions for custom lightbox props - https://yet-another-react-lightbox.com/advanced#CustomLightboxProps

After that you can pass your custom props to the Lightbox component and access them in your plugin module.

import Lightbox, { ComponentProps, createModule, PluginProps } from "yet-another-react-lightbox";

declare module "yet-another-react-lightbox" {
  interface LightboxProps {
    sidebar?: {
      onButtonClick?: () => void;
    };
  }
}

function LightboxSidebar({ children, sidebar: { onButtonClick } = {} }: ComponentProps) {
  return (
    <>
      {children}
      {/* ... */}
    </>
  );
}

function SidebarPlugin({ addModule }: 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@BabkinAV
Comment options

Answer selected by BabkinAV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants