Skip to content

Commit

Permalink
Adding onLoaded callback for RedocStandalone (#128)
Browse files Browse the repository at this point in the history
Co-authored-by: Rohit Gohri <work@rohit.page>
  • Loading branch information
David Liu and rohit-gohri committed Mar 2, 2022
1 parent 9e66c76 commit 0e862a5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-wasps-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"docusaurus-theme-redoc": minor
---

Adding onLoaded callback for RedocStandalone
3 changes: 2 additions & 1 deletion packages/docusaurus-theme-redoc/src/theme/Redoc/Redoc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function Redoc(props: Props): JSX.Element {
'docusaurus-theme-redoc',
);
const theme = isDarkTheme ? darkTheme : lightTheme;
const { spec, specUrl } = props;
const { spec, specUrl, onLoaded } = props;
const store = useMemo(() => {
if (!spec) return null;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -39,6 +39,7 @@ function Redoc(props: Props): JSX.Element {
...redocOptions,
theme,
}}
onLoaded={onLoaded}
/>
)}
</div>
Expand Down
11 changes: 8 additions & 3 deletions packages/docusaurus-theme-redoc/src/types/common.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import type { Props as LayoutProps } from '@theme/Layout';
import type { RedocRawOptions, ObjectDescriptionProps } from 'redoc';
import type {
RedocRawOptions,
ObjectDescriptionProps,
RedocStandaloneProps,
} from 'redoc';
import type { RecursivePartial } from './util';

export type RedocProps = {
export interface RedocProps
extends Omit<RedocStandaloneProps, 'spec' | 'specUrl' | 'options'> {
spec?: Record<string, unknown>;
specUrl?: string;
};
}

export type ApiSchemaProps = Omit<
ObjectDescriptionProps,
Expand Down

0 comments on commit 0e862a5

Please sign in to comment.