emotion
emotion copied to clipboard
Type '{ children: string; css: SerializedStyles; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.
Code Used
import React from "react";
import { css } from "@emotion/react";
const color = "white";
const App = () => {
return (
<>
<div
css={css`
padding: 32px;
background-color: hotpink;
font-size: 24px;
border-radius: 4px;
text-align: center;
cursor: pointer;
&:hover {
color: ${color};
}
`}
>
Hover to change color.
</div>
</>
);
};
export default App;
Message in Problem Tab (VSCODE)
Type '{ children: string; css: SerializedStyles; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.
Property 'css' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.
Additional Note
With the message popping in the problem tab. The css properties too were not applied on the page.
Environment information:
-
react
version: 18.2.0 -
@emotion/react
version: 11.11.1
same problem
import { type SerializedStyles } from '@emotion/react'
declare module 'react' {
interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
flex?: boolean
relative?: boolean
text?: string
grid?: boolean
before?: string
after?: string
shadow?: boolean
w?: string
h?: string
bg?: string
rounded?: string
fixed?: boolean
b?: string
z?: string
block?: boolean
'focus:shadow'?: boolean
css?: SerializedStyles
}
interface SVGProps<T> extends SVGAttributes<T>, ClassAttributes<T> {
w?: string
h?: string
}
}