cssinjs/jss

Styles created multiple times when using function values

开放

#1,361 创建于 2020年7月3日

 (8 条评论) (6 个反应) (0 位负责人)JavaScript (434 个派生)batch import
bughelp wantedimportantperf

仓库指标

星标
 (7,000 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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

贡献者指南