Skip to content

Commit 72f7446

Browse files
committed
chore(sidenav): stop using FunctionComponent to pass CI
1 parent 4dea5c3 commit 72f7446

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

packages/sidenav/src/index.tsx

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ const flattenLinks = (children: ReactNode): ReactNode[] =>
5050
return acc
5151
}, [])
5252

53-
const Overlay: FunctionComponent<{
53+
interface OverlayProps {
5454
onClick?: EventHandler<MouseEvent<HTMLDivElement>>
55-
}> = ({ onClick }) => (
55+
}
56+
const Overlay = ({ onClick }: OverlayProps) => (
5657
<React.Fragment>
5758
<div
5859
onClick={onClick}
@@ -80,7 +81,7 @@ export const Sidenav = forwardRef<
8081
open?: boolean
8182
components?: MDXProviderComponents
8283
styles?: ThemeStyles
83-
children: ReactNode
84+
children?: ReactNode
8485
}
8586
>(({ open, styles = {}, components = {}, ...props }, ref) => {
8687
return (
@@ -112,7 +113,7 @@ export const Sidenav = forwardRef<
112113
),
113114
}}
114115
>
115-
{open && <Overlay {...props} />}
116+
{open && <Overlay />}
116117
<MDXProvider components={components}>
117118
<div
118119
{...props}
@@ -198,7 +199,11 @@ const NavLinks: FunctionComponent<{
198199
pathname: string
199200
links: ReactComponentElement<'a'>[]
200201
href: string
201-
Link: React.FunctionComponent<{ href?: string; className?: string }>
202+
Link: React.FunctionComponent<{
203+
href?: string
204+
className?: string
205+
children?: ReactNode
206+
}>
202207
}> = ({ open, pathname = '', links, href, Link }) => {
203208
if (!links) return null
204209
if (!open && !pathname.includes(href)) return null
@@ -325,12 +330,22 @@ export const AccordionNav = forwardRef<
325330
const removeSlash = (str: string) =>
326331
str.length > 1 ? str.replace(/\/$/, '') : str
327332

328-
const PaginationLink: FunctionComponent<{
333+
interface PaginationLinkProps {
329334
label: string
330335
mdxType: string
331336
originalType: string
332337
parentName: string
333-
}> = ({ label, children, mdxType, originalType, parentName, ...props }) => (
338+
children: ReactNode
339+
}
340+
341+
const PaginationLink = ({
342+
label,
343+
children,
344+
mdxType,
345+
originalType,
346+
parentName,
347+
...props
348+
}: PaginationLinkProps) => (
334349
<a
335350
{...props}
336351
sx={{
@@ -351,10 +366,18 @@ const PaginationLink: FunctionComponent<{
351366
</a>
352367
)
353368

354-
export const Pagination: FunctionComponent<{
369+
export interface PaginationProps {
355370
pathname: string
356371
components?: any
357-
}> = ({ pathname = '', children, components, ...props }) => {
372+
children?: ReactNode
373+
}
374+
375+
export const Pagination = ({
376+
pathname = '',
377+
children,
378+
components,
379+
...props
380+
}: PaginationProps) => {
358381
const links = flattenLinks(children)
359382
const index = links.findIndex(
360383
(link) =>

packages/sidenav/test/index.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,18 @@
66
import { jsx } from 'theme-ui'
77
import renderer from 'react-test-renderer'
88
import { render, cleanup, act } from '@theme-ui/test-utils'
9-
import { FunctionComponent } from 'react'
9+
import { ReactNode } from 'react'
1010

1111
import { Sidenav, Pagination, AccordionNav } from '../src'
1212

1313
afterEach(cleanup)
1414

15-
const Link: FunctionComponent<{
16-
href: string
17-
mdxType: 'a'
18-
}> = (props) => {
15+
const Link = (props: { href: string; mdxType: 'a'; children: ReactNode }) => {
1916
const { children, ...rest } = props
2017
return <a {...rest}>{children}</a>
2118
}
2219

23-
const Ul: FunctionComponent<{ mdxType: 'ul' }> = (props) => {
20+
const Ul = (props: { mdxType: 'ul'; children: ReactNode }) => {
2421
const { children, ...rest } = props
2522
return <ul {...rest}>{children}</ul>
2623
}

0 commit comments

Comments
 (0)