Skip to content

Commit

Permalink
Merge pull request #193 from Spartakyste/chore/sfc-types
Browse files Browse the repository at this point in the history
chore: Updated React component typing
  • Loading branch information
damassi committed Jul 22, 2021
2 parents cf1664f + 0b8cc2c commit 5c30c32
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
14 changes: 7 additions & 7 deletions examples/kitchen-sink/src/App.tsx
Expand Up @@ -35,7 +35,7 @@ const LargeStyle: CSSProperties = {
}

// From https://www.smashingmagazine.com/2013/07/simple-responsive-images-with-css-background-images/
const Img: React.SFC<
const Img: React.FunctionComponent<
{ src: string; aspectRatio: number } & React.HTMLProps<HTMLSpanElement>
> = ({ src, aspectRatio, style, ...props }) => (
<span
Expand Down Expand Up @@ -63,7 +63,7 @@ const Img: React.SFC<
</span>
)

export const App: React.SFC = () => (
export const App: React.FunctionComponent = () => (
<div>
<div>
<h1>
Expand All @@ -88,11 +88,11 @@ export const App: React.SFC = () => (
</h1>
<ul style={{ listStyleType: "none", padding: "0", margin: "0" }}>
{/* prettier-ignore
*
* These line-items can’t be wrapped by a div, so use a render prop to
* receive the class name and a hint as to wether children should be
* rendered.
*/}
*
* These line-items can’t be wrapped by a div, so use a render prop to
* receive the class name and a hint as to wether children should be
* rendered.
*/}
<Media lessThan="sm">
{className => (
<li className={className} style={ExtraSmallStyle}>
Expand Down
6 changes: 4 additions & 2 deletions src/DynamicResponsive.tsx
Expand Up @@ -42,9 +42,11 @@ export function createResponsiveComponents<M extends string>() {
const ResponsiveContext = React.createContext({})
ResponsiveContext.displayName = "Media.DynamicContext"

const ResponsiveConsumer: React.SFC<
const ResponsiveConsumer: React.FunctionComponent<
React.ConsumerProps<MediaQueryMatches<M>>
> = ResponsiveContext.Consumer as React.SFC<React.ConsumerProps<any>>
> = ResponsiveContext.Consumer as React.FunctionComponent<
React.ConsumerProps<any>
>

return {
Consumer: ResponsiveConsumer,
Expand Down
2 changes: 1 addition & 1 deletion src/Media.tsx
Expand Up @@ -338,7 +338,7 @@ export function createMedia<
}>({ hasParentMedia: false, breakpointProps: {} })
MediaContext.displayName = "MediaParent.Context"

const MediaContextProvider: React.SFC<
const MediaContextProvider: React.FunctionComponent<
MediaContextProviderProps<BreakpointKey | Interaction>
> = ({ disableDynamicMediaQueries, onlyMatch, children }) => {
if (disableDynamicMediaQueries) {
Expand Down

0 comments on commit 5c30c32

Please sign in to comment.