cssinjs / cssinjs/jss

Styles created multiple times when using function values

Open
#1,361 8 comments 6 reactions 0 assignees View on GitHub
bug help wanted important perf
Dominant language
JavaScript
Stars
7.1k
Forks
386
PR merge metrics
No merged PRs in 30d

Description

__Expected behavior:__
Duplicate styles shouldn't be created.

__Describe the bug:__
On every component render, in which useStyles prop changes, new duplicate styles are created. I've managed to reproduce the bug in Codesandbox. To see it:

1. Open codesandbox link from below
2. Inspect red text element and see styles applied
3. Click on button few times to cause component re-render
4. Inspect some another element on the page and the red text again.
5. Notice duplicate styles
The styles are duplicated only for elements styled with css selector. If you check styles on the element with container class, you'll see there is no duplication there.

__Codesandbox link:__
https://codesandbox.io/s/react-jss-playground-7ftrs?file=/index.js

__Versions (please complete the following information):__
- jss: 10.1.1
- Browser [e.g. chrome, safari]: any
- OS [e.g. Windows, macOS]: any
79044719-7820f180-7c0f-11ea-9134-42442b8c84af

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.