Skip to content

Commit

Permalink
Extract BodyPortal props type and fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Dantemss committed Aug 26, 2024
1 parent 8db17f5 commit f7337d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/BodyPortal.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe('BodyPortal', () => {
});

it('accepts an optional ref parameter that will be set', () => {
const TestPortal = ({ children }: React.PropsWithChildren<{}>) => {
const TestPortal = ({ children }: React.PropsWithChildren<unknown>) => {
const ref = React.useRef<HTMLElement | null>(null);
expect(ref.current).toBeNull();

Expand Down
8 changes: 6 additions & 2 deletions src/components/BodyPortal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ const getInsertBeforeTarget = (bodyPortalSlots: string[], slot?: string) => {
return null;
}

export const BodyPortal = React.forwardRef<HTMLElement, React.PropsWithChildren<{
export type BodyPortalProps = React.PropsWithChildren<{
className?: string;
role?: string;
slot?: string;
tagName?: string;
}>>(({ children, className, role, slot, tagName }, ref) => {
}>;

export const BodyPortal = React.forwardRef<HTMLElement, BodyPortalProps>((
{ children, className, role, slot, tagName }, ref?: React.ForwardedRef<HTMLElement>
) => {
const tag = tagName?.toUpperCase() ?? 'DIV';
const internalRef = React.useRef<HTMLElement>(document.createElement(tag));
if (internalRef.current.tagName !== tag) {
Expand Down

0 comments on commit f7337d2

Please sign in to comment.