Aphrodite Duplicating ClassName on SSR
- Dominant language
- JavaScript
- Stars
- 5.3k
- Forks
- 187
- PR merge metrics
- No merged PRs in 30d
Description
Hey guys, I'm using Next.js to server side render my app. I have some components that render solely on the client, and some that render on the server.
I tried utilizing Aphrodite's StyleSheet.rehydrate, but I don't see it working, and my styles from the server are clobbering my styles from the client (they become the same className, even though they're different styles).
```javascript
if (typeof window !== 'undefined') {
/* StyleSheet.rehydrate takes an array of rendered classnames,
and ensures that the client side render doesn't generate
duplicate style definitions in the tag */
StyleSheet.rehydrate(window.__NEXT_DATA__.ids)
}
```
`window.__NEXT_DATA__.ids` is the list of classNames that were already rendered on the server.
Any idea what's going on here?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the SSR and client-rendering setup described in the issue, focusing on StyleSheet.rehydrate and window.__NEXT_DATA__.ids. Reproduce the duplicate className case and verify that server-rendered and client-rendered styles no longer collide.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, next.js
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100