Skip to content

Need to detach sheet for addRule with function values #475

@lttb

Description

@lttb

Online Example

If we add new rule with just function values, .update() does not work for this new rule:

const styles = {
  title: {
    fontSize: 20,
    color: ({color}) => color
  }
}

const sheet = jss.createStyleSheet(styles, {link: true}).attach()
sheet.addRule('subtitle', {color: ({color}) => color})
sheet.update({color: 'red'}) // still no color for subtitle, with attach() then too
// but if we call .deploy() - color applies

But this works:

const sheet2 = jss.createStyleSheet(styles, {link: true}).attach()
sheet2.detach()
sheet2.addRule('subtitle', {color: ({color}) => color})
sheet2.update({color: 'red'}).attach() // red color for subtitle too

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIt went crazy and killed everyone.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions