question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamically generated classes ignored

See original GitHub issue

I am trying to have a dynamic list of items and give each a sequentially calculated class, a spinner where I can just say the number of parts and they will be spaced automatically. This is partial code without the whole animation CSS:

const styles = theme => ({
  letters: {
    position: 'absolute'
  },
  letter: getLetterClasses(5),
  'letter-0': { left: 50 }
})

const getLetterClasses = (number) => {
  let list = {}

  for (let i = 0; i < number; i++) {
    list[`&-${i}`] = { left: 20 * i }
  }

  return list
}

//=============

const spinner = spinner_array.map((letter, i) => {
  const cls = classnames(classes.letters, classes[`letter-${i}`])
  return <div className={cls} key={i}>{letter}</div>
})

This only works when I create each class explicitly, like letter-0, but ignores the dynamic part. I have no idea why since the object generation seems to work correctly. https://codesandbox.io/s/30w6l0v786

  • jss: 8.6.1
  • Chrome 69
  • macOS Mojave

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kofcommented, Oct 12, 2018

Your problem is not with JSS, but with how you use the classes. I fixed your class name concatentation https://codesandbox.io/s/k3nj04j9po

1reaction
HenriBeckcommented, Oct 12, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

React and Tailwind CSS: dynamically generated classes are ...
Tailwind's JIT mode scans your codebase for class names, and generates CSS based on what it finds. If a class name is not...
Read more >
Use Dynamically Generated Classes as Mixins #1399 - GitHub
It would ignore returned from calls after its definition. So this: #outer { // enclosure around original case @a: "a"; .mixin() { @a:...
Read more >
How to map a class with dynamically generated class in ...
I have generated new dynamic class which can hold customer and its custom fields as properties instead of collections like:.
Read more >
Ignored classes could not be matched to its original source file
Ignored classes could not be matched to its original source file ... It might be a dynamically generated class.
Read more >
Assigning FileNet P8 classes or properties dynamically - IBM
Assigning properties dynamically allows you to work with properties that might not be present in all dynamically assigned document and record classes. About ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found