Skip to content

Commit f7337d2

Browse files
committed
Extract BodyPortal props type and fix lint
1 parent 8db17f5 commit f7337d2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/components/BodyPortal.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ describe('BodyPortal', () => {
181181
});
182182

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

src/components/BodyPortal.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ const getInsertBeforeTarget = (bodyPortalSlots: string[], slot?: string) => {
2121
return null;
2222
}
2323

24-
export const BodyPortal = React.forwardRef<HTMLElement, React.PropsWithChildren<{
24+
export type BodyPortalProps = React.PropsWithChildren<{
2525
className?: string;
2626
role?: string;
2727
slot?: string;
2828
tagName?: string;
29-
}>>(({ children, className, role, slot, tagName }, ref) => {
29+
}>;
30+
31+
export const BodyPortal = React.forwardRef<HTMLElement, BodyPortalProps>((
32+
{ children, className, role, slot, tagName }, ref?: React.ForwardedRef<HTMLElement>
33+
) => {
3034
const tag = tagName?.toUpperCase() ?? 'DIV';
3135
const internalRef = React.useRef<HTMLElement>(document.createElement(tag));
3236
if (internalRef.current.tagName !== tag) {

0 commit comments

Comments
 (0)