Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Updated React component typing #193

Merged
merged 1 commit into from Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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<
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(non-blocking) -- note you can also use the abbreviated version, React.FC

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, hesitated for a bit, but I find abbreviation confusing in code (interpretation differ from peoples), which is why I choose this way. Thanks for the feedback :D

{ 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