Un-mount and re-mount JssProvider
See original GitHub issueExpected behavior: Expect dynamically generated style names and statically generated style names to be unique
Describe the bug: I have a component wrapped by a JssProvider and Theme provider eg.
const jss = createJss()
jss.use(global(), nested(), extend(), compose(), camelCase(), vendorPrefixer())
<JssProvider classNamePrefix={this.props.classNamePrefix} jss={jss}>
<ThemeProvider theme={this.props.theme}>
{this.props.children}
</ThemeProvider>
</JssProvider>
When I unmount this component and re-mount this component, any dynamically generated styles in the child components now have style names that clash with the original statically generated styles.
Codesandbox link: Only happens in production. Will try to write an example soon
Versions:
- jss: “jss”: “^9.8.1”, “jss-camel-case”: “^6.1.0”, “jss-compose”: “^5.0.0”, “jss-global”: “^3.0.0”, “jss-nested”: “^6.0.1”, “jss-vendor-prefixer”: “^8.0.1”,
- Browser [e.g. chrome, safari]: latest Chrome (Version 70.0.3538.77 (Official Build) (64-bit) ), latest Firefox (63.0 (64-bit))
- OS [e.g. Windows, macOS]: Ubuntu 18.10
Issue Analytics
- State:
- Created 5 years ago
- Comments:20 (17 by maintainers)
Top Results From Across the Web
React unmount and remount child component - Stack Overflow
For example, is there a way for me to unmount and mount again a child component based on the parent component's "componentWillReceiveProps"?
Read more >Using React's Key Attribute to remount a Component - Nik Graf
First we checkout how React's key can be used, then walk through a real world scenario and finally discuss if we should use...
Read more >JSS integration with React
... Sheets are created when a component mounts and removed when it's unmounted. ... 'react-dom' import {JssProvider} from 'react-jss' import MyApp from '....
Read more >Solve React 18 mount, unmount, remount in Strict Mode
React 18 introduced a breaking change. In Strict Mode, all components mount and unmount. solve this by using a useEffectOnce hook as workaround....
Read more >Avoid unnecessary remounting of DOM elements in React
Log to the console when it's mounted and unmounted from the DOM. class ... I expected React to not unmount and then remount...
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
Do we have a test that makes sure this keeps working?
It seems v10 of
react-jss
has the issue fixed regardless of whether re-usinggenerateId
or not: Previously with v8 the static ID generator was re-used but the dynamic style Id started from scratch…v8
First mount Remount Notice how the dynamic style classes have an ID generated that clash with the static styles on the re-mount. At this stage I’m not sure what was the cause of this, or why the same IDs for static styles were used.
v10
First mount Remount In v10 regardless of whether
generateId
was passed in as a prop, it seems to keep around the pointer to the generator used when re-mounting and increment both the static and dymanic style IDs.