Styles are not removed after unmounting a component
- Dominant language
- JavaScript
- Stars
- 7.1k
- Forks
- 386
- PR merge metrics
- No merged PRs in 30d
Description
__Expected behavior:__
When a component unmounts its stylesheets should be removed from the head.
__Describe the bug:__
The stylesheets attached to the head don't include the name of the component in the `data-meta` attribute. I guess this is why JSS can't remove the stylesheet when the component unmounts.
__Reproduction:__
I can reproduce the error with `react-jss@10.7.1` using the `withStyles` HOC or the `createUseStyles` hook.
But in the `10.6.0` version it just happens with the hook. The styles attached with the HOC work fine.
Here is an example in [Codesandbox](https://codesandbox.io/s/cranky-burnell-1uhvi). In the example I'm using version 10.6.0. If the version is changed to 10.7.1 non of the cases works.
__Versions (please complete the following information):__
Dependencies:
```
"react": "17.0.2",
"react-dom": "17.0.2",
"react-jss": "10.6.0",
"react-scripts": "4.0.0"
```
- Browser: Chrome
- OS: Windows
__Managing expectations:__
I've been seeing the `Warning: [JSS] Rule is not linked. Missing sheet option "link: true".` message in the terminal (not in codesandbox but in my Next.js project), but no idea if it is related.
Contributor guide
Assessment
This issue has not been assessed yet.