user633597
user633597

Reputation: 139

Converting a .jsx file using Tailwindcss Typescript error

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}
    />
  )
}

Upvotes: 0

Views: 153

Answers (1)

Johnny Missile
Johnny Missile

Reputation: 292

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} />
}

Upvotes: 1

Related Questions