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

Typography : genericFontFamily error #39

Closed
jinhojang6 opened this issue May 22, 2023 · 0 comments
Closed

Typography : genericFontFamily error #39

jinhojang6 opened this issue May 22, 2023 · 0 comments

Comments

@jinhojang6
Copy link
Contributor

When using a Typograpgy component with the genericFontFamily property, a browser consoles shows this error

Warning: React does not recognize the `genericFontFamily` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `genericfontfamily` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
Screenshot 2023-05-22 at 9 01 10 PM

I can remove the error if I pick up genericFontFamily from Typography.tsx as below but not sure if this could have a side effect.

export const Typography: React.FC<TypographyProps> & {
  classes: typeof typographyClasses
} = ({
  color,
  variant = 'body1',
  component,
  className,
  children,
  genericFontFamily,  // change1
  ...props
}) => {
  const commonProps = useCommonProps({ ...props, genericFontFamily })  // change2
  const componentName =
    component ??
    (
      {
        h1: 'h1',
        h2: 'h2',
        h3: 'h3',
        h4: 'h4',
        h5: 'h5',
        h6: 'h6',
        label1: 'label',
        label2: 'label',
      } as Record<TypographyVariants, string>
    )[variant] ??
    'span'

  const Component = componentName as any as React.ComponentType<TypographyProps>

  return (
    <Component
      className={clsx(
        commonProps.className,
        typographyClasses.root,
        typographyClasses[variant],
        color && typographyClasses[color],
        className,
      )}
      {...props}
    >
      {children}
    </Component>
  )
}

Typography.classes = typographyClasses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant