I'm witnessing a weird behavior when using styled-components with remix / SSR
To Reproduce this issue, navigate to https://ieee-nu-store-dt1asq0sv-omarkhled.vercel.app/ and you will find a ProdcutCard component on the root route, navigate to any other route and return back, and will find that the style of the cart button in the ProductCart Component did change
Expected Behavior
The ProductcCard Component Should be rendered as follows
Actual Behavior
The component renders fine on the first render on the root route, but after hitting any other route and returning back to the root route it breaks and shows as follows:
The code for the ProductCard Component is as follows
const Button = styled.button<{ mode: "primary" | "secondary" | "dark" }>`
display: grid;
/* justify-content: center; */
align-items: center;
text-align: center;
color: var(--mintCream);
padding: ${clamp(9, 10)} ${clamp(20, 30)}; // this clamp function just generates the css clamp func with calculating the values with some equations
box-shadow: var(--box-shadow-md);
border: var(--border-md);
border-radius: 12px;
text-decoration: none;
cursor: pointer;
transition: all 500ms ease;
font-size: ${clamp(13, 16)};
&:disabled {
cursor: not-allowed;
opacity: 0.7;
}
@media (hover: hover) and (pointer: fine) {
&:hover:enabled {
transform: translateY(-2px); }
}
width: fit-content;
`;
This problem only happens in production and works fine on the local server...
On inspecting elements, I find that the class name of the Cart Component is also injected into the ShareButton Element
I don't know whether the cause of this behavior is something in styled-components or the SSR in remix.run but I think this issue is relevant #1032
I get the error Warning: Prop `className` did not match. Server: "sc-dUWWNf kGyxhI" Client: "sc-iqcoie JlZYN" also as the above issue.
What version of Remix are you using?
1.5.1
Steps to Reproduce
I'm witnessing a weird behavior when using styled-components with remix / SSR
To Reproduce this issue, navigate to https://ieee-nu-store-dt1asq0sv-omarkhled.vercel.app/ and you will find a ProdcutCard component on the root route, navigate to any other route and return back, and will find that the style of the cart button in the ProductCart Component did change
Expected Behavior
The ProductcCard Component Should be rendered as follows
Actual Behavior
The component renders fine on the first render on the root route, but after hitting any other route and returning back to the root route it breaks and shows as follows:
The code for the ProductCard Component is as follows
ProductCard.tsx
Button.tsx
This problem only happens in production and works fine on the local server...
On inspecting elements, I find that the class name of the Cart Component is also injected into the ShareButton Element
I don't know whether the cause of this behavior is something in styled-components or the SSR in remix.run but I think this issue is relevant #1032 I get the error
Warning: Prop `className` did not match. Server: "sc-dUWWNf kGyxhI" Client: "sc-iqcoie JlZYN"
also as the above issue.Can you guide me through this?