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.

A strange off-by-one problem – incorrect style is applied sometimes

See original GitHub issue

I’m trying to debug a problem where material-ui-kit pulls in material-ui that uses jss and I use it all with gatsby’s SSR.

I’ll work on a minimal reproducible build but what I see insofar is that sometimes jss is rendered incorrectly and all the elements get assigned jss+1 indices, exploding the page at random. It seems to be pretty consistent in that +1, e.g.

image

is a good render, while

image

is a bad one.

While I hunt for what exactly triggers the bad behavior, any ideas what could possibly cause this N+1?

npm ls|grep jss
│ ├─┬ @types/jss@9.5.7
│ ├─┬ jss@9.8.7
│ ├─┬ jss-camel-case@6.1.0
│ ├── jss-default-unit@8.0.2
│ ├── jss-global@3.0.0
│ ├─┬ jss-nested@6.0.1
│ ├── jss-props-sort@6.0.0
│ ├─┬ jss-vendor-prefixer@7.0.0
└─┬ react-jss@8.6.1
  ├── jss@9.8.7 deduped
  ├─┬ jss-preset-default@4.5.0
  │ ├── jss-camel-case@6.1.0 deduped
  │ ├─┬ jss-compose@5.0.0
  │ ├── jss-default-unit@8.0.2 deduped
  │ ├── jss-expand@5.3.0
  │ ├─┬ jss-extend@6.2.0
  │ ├── jss-global@3.0.0 deduped
  │ ├── jss-nested@6.0.1 deduped
  │ ├── jss-props-sort@6.0.0 deduped
  │ ├─┬ jss-template@1.0.1
  │ └── jss-vendor-prefixer@7.0.0 deduped

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:35 (27 by maintainers)

github_iconTop GitHub Comments

1reaction
oliviertassinaricommented, Oct 27, 2018

@kof I get issues like this one all the time on Material-UI. We have been documenting the workarounds in the documentation, it’s a bit better now. But people are struggling with the index counter approach. I have been personally hit multiple times by the problem. It doesn’t leave any room for mistake. I wish we can explore a hash-based generation logic in the future.

1reaction
kofcommented, Oct 26, 2018

In your example you are using createGenerateClassName from MUI, not from react-jss. One of the reasons could be that the way class names generator is used differently on the client and server. We need to see some working code to understand exactly how.

cc @oliviertassinari

Read more comments on GitHub >

github_iconTop Results From Across the Web

Off-by-one error - Wikipedia
An off-by-one error or off-by-one bug is a logic error involving the discrete equivalent of a boundary condition. It often occurs in computer...
Read more >
What is an off-by-one error and how do I fix it? - Stack Overflow
An off-by-one error is for example when you intend to perform a loop n times and write something like: for (int i =...
Read more >
Errors and exceptions - Object-Oriented Programming in Python
Sometimes there can be absolutely nothing wrong with your Python implementation of an algorithm – the algorithm itself can be incorrect. However, more ......
Read more >
Errors and exceptions — Object-Oriented Programming in ...
Sometimes there can be absolutely nothing wrong with your Python implementation of an algorithm – the algorithm itself can be incorrect. However, more ......
Read more >
Debugging | CS 61A Summer 2022
Most often, you will try to run your code and see something like this: ... the doctests tell you where the error is,...
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