Next.js with Preact 10.5.2 and preact-compat
https://codesandbox.io/s/strange-smoke-jbhx6?file=/pages/index.js
"dependencies": {
"@prefresh/next": "1.2.0",
"clsx": "1.1.1",
"next": "latest",
"preact": "^10.5.2",
"preact-render-to-string": "5.1.10",
"react": "github:preact-compat/react#1.0.0",
"react-dom": "github:preact-compat/react-dom#1.0.0",
"react-ssr-prepass": "npm:preact-ssr-prepass@^1.0.1"
},
default-class){ className, ...otherProps })clsx("default-class", className))<div className={clsx("default-class", className} {...otherProps}>...</div>In Preact 10.4.8 there was no problem. In Preact 10.5.2 with preact-compat we are seeing both class and className being passed to the component via props.
Our otherProps contains class which gets spread onto the div after className.
The class now only contains ONLY the additional className and not the default className.
My current workaround is to apply className after spreading otherProps.
Also experiencing same issue.
Here's a repro:
export default function Home() {
return (
<div>
<MyComponent className="foo" />
<style>{`
div { height: 100px }
.foo { background: red; }
.bar { background: green; }
`}</style>
</div>
)
}
const MyComponent = ({ className, ...props }) => {
return <div className={`${className} bar`} {...props} />
}
Div to be green
Div is red
Ahh, sorry this one's on me - I had forgotten about folks relying on className taking precedence over class when spreading props. I'll add these as tests for #2774 to make sure it covers the breakage.
Just published 10.5.3 which includes the fix for this issue :tada:
Most helpful comment
Also experiencing same issue.
Here's a repro:
Expected:
Div to be green
Actual:
Div is red