0

I copy an example code from the Tailwind sight. When I changed the file to a .tsx I get an error with the className.

Do I need to define a type

What do I need to do to make the error go away?

Binding element 'className' implicitly has an 'any' type.

import clsx from 'clsx'

export function Container({ className, ...props }) {
  return (
    <div
      className={clsx('mx-auto max-w-7xl px-4 sm:px-6 lg:px-8', className)}
      {...props}
    />
  )
}
1
  • you need to provide types for props, so try Container({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) Commented Sep 27, 2022 at 5:59

1 Answer 1

1
import clsx from 'clsx'

interface ContainerProps {
    className: string
}

export function Container({ className, ...props }: ContainerProps) {
    return <div className={clsx('mx-auto max-w-7xl px-4 sm:px-6 lg:px-8', className)} {...props} />
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.