Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to declare type for CSS class in typescript?

     import React, { FC } from "react";
     import { IUser } from "../types/Types";
     import App from "../App";
     interface UserItemProps {
     user: IUser;
     ClassName: React.CSSProperties;
      }
       const UserItem: FC<UserItemProps> = ({ user }) => {
        return (
         <div ClassName="UserPage">
         {user.id}.{user.name}.{user.email} lives {user.address.city} street{" "}
         {user.address.street}
         </div>
         );
        };

     export default UserItem;

CSS

     .UserPage{
      width:1400px;
      height:hug 164px;
      border-radius:8px;
      padding:24px, 16px, 24px, 16px;
      gap:32px;

      }

Error:
Type ‘{ children: (string | number)[]; ClassName: string; }’ is not assignable to type ‘DetailedHTMLProps<HTMLAttributes, HTMLDivElement>’.
Property ‘ClassName’ does not exist on type ‘DetailedHTMLProps<HTMLAttributes, HTMLDivElement>’. Did you mean ‘className’?

how can i declare css type?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

In your div component, you have used className With capital C, you need to write it like className

     <div className="UserPage">
       {user.id}.{user.name}.{user.email} lives {user.address.city} 
         street{""}
       {user.address.street}
     </div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading