Skip to content

Commit

Permalink
Uses "React.FC" instead of "React.FunctionComponent"
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Nov 6, 2019
1 parent ce1ec3e commit 5b40cec
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/components/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface BoxProps extends GenericProps {
inline?: boolean
}

const Box: React.FunctionComponent<BoxProps> = styled.div<BoxProps>`
const Box: React.FC<BoxProps> = styled.div<BoxProps>`
display: ${({ flex, inline }) =>
flex
? inline
Expand Down
8 changes: 5 additions & 3 deletions src/components/MediaQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import normalizeQuery from '@src/utils/styles/normalizeQuery'
import transformNumeric from '@utils/math/transformNumeric'
import compose from '@src/utils/functions/compose'

interface Props extends MediaQueryParams {
interface MediaQueryProps extends MediaQueryParams {
children: (matches: boolean) => JSX.Element
matches?: boolean
}
Expand All @@ -30,9 +30,11 @@ const createMediaQuery = (queryParams: MediaQueryParams): string => {
)(queryParams)
}

const MediaQuery = (props: Props): JSX.Element => {
const MediaQuery: React.FC<MediaQueryProps> = (props) => {
const { children, ...queryParams } = props
const query = React.useMemo(() => createMediaQuery(queryParams), [queryParams])
const query = React.useMemo(() => createMediaQuery(queryParams), [
queryParams,
])
const [matches, setMatches] = React.useState(false)

const handleMediaQueryChange = (
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useResponsiveComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ function useResponsiveComponent<
OwnProps extends Record<string, any>,
ResponsiveProps extends Record<string, Numeric>
>(
Component: React.FunctionComponent<OwnProps>,
): React.FunctionComponent<OwnProps & Partial<ResponsiveProps>> {
Component: React.FC<OwnProps>,
): React.FC<OwnProps & Partial<ResponsiveProps>> {
return (responsiveProps) => {
/**
* @see https://github.com/Microsoft/TypeScript/issues/29049
Expand Down
9 changes: 3 additions & 6 deletions src/utils/templates/generateComponents/generateComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { GenericProps } from '@const/props'
import MediaQuery from '@components/MediaQuery'
import Box, { BoxProps } from '@components/Box'
import capitalize from '@utils/strings/capitalize'
import getAreaRecords, { AreaRecord } from '@utils/breakpoints/getAreaRecords'
import getAreaRecords from '@utils/breakpoints/getAreaRecords'

export type AreaComponent = React.FunctionComponent<BoxProps>
export type AreaComponent = React.FC<BoxProps>
export interface AreasMap {
[componentName: string]: AreaComponent
}
Expand All @@ -21,10 +21,7 @@ export const withPlaceholder = (
Component: AreaComponent,
breakpoints: Breakpoint[],
) => {
const Placeholder: React.FunctionComponent<GenericProps> = ({
children,
...restProps
}) => {
const Placeholder: React.FC<GenericProps> = ({ children, ...restProps }) => {
const PlaceholderComponent = breakpoints.reduce<JSX.Element[]>(
(components, breakpoint, index) => {
return components.concat(
Expand Down

0 comments on commit 5b40cec

Please sign in to comment.