A strange off-by-one problem – incorrect style is applied sometimes
See original GitHub issueI’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.
is a good render, while
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:
- Created 5 years ago
- Reactions:1
- Comments:35 (27 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
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