-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test HTML produced on server hydrates without errors on client-side #2
Comments
I got mismatched error when using |
Can you please post the code that produces this error? |
@overlookmotel I setup global state and use it as a const { setGlobal, getGlobal, addReducer, resetGlobal } = require('reactn');
const LRU = require('lru_map').LRUMap
const LIMIT = 10
const setupGlobal = ({cache}) => {
setGlobal({
cache
});
addReducer('setCache', (global, key, record) => {
global.cache.set(key, record)
return {
cache: global.cache
}}
);
addReducer('evictCache', (global, key) => {
//delete(global.cache, key)
global.cache.delete(key)
return {
cache: global.cache
}}
);
}
export const setupGlobalCache = (limit = LIMIT) => {
resetGlobal()
let cache = new LRU(limit);
setupGlobal({cache})
}
export const getGlobalCache = () => {
const cache = getGlobal().cache.toJSON()
return {
cache
}
}
export const loadGlobalCache = (serialized, limit = LIMIT) => {
resetGlobal()
const cache = new LRU(serialized)
window.__CACHE__ = cache
//cache.fromJSON(serialized.cache)
setupGlobal({cache})
} Then do serialization on const globalValue = getGlobalCache().cache.map(it => [it.key, it.value])
...
<script id='graphql-state'>
window.__PRELOADED_STATE__=${serialize({cache:globalValue})}
</script> Then on import { loadGlobalCache } from './ssr/lru-cache'
loadGlobalCache(window.__PRELOADED_STATE__.cache)
loadableReady(() => {
const sheetsManager = new Map();
const generateClassName = createGenerateClassName();
hydrate(
<JssProvider generateClassName={generateClassName}>
<MuiThemeProvider sheetsManager={sheetsManager} theme={theme}>
<App />
</MuiThemeProvider>
</JssProvider>
) |
I think, because |
@revskill10 There's a lot of moving parts here. Are you able to simplify it? I can't really investigate this as I am missing a lot of the pieces:
If you can't reduce the example's complexity, can you share all the code as a repo so I can run it and replicate the case on my machine? At this point, I haven't got a clue where to start! |
@overlookmotel Please give me some days to reproduce on a minimal repo !
This is not much different from the |
Sure. Thank you very much for your effort. |
By the way, did you mean |
@overlookmotel Yes, it's |
@overlookmotel I retested with apollo-client and everything works fine. This is a non-issue. |
@revskill10 OK great. Thanks for letting me know. |
I think it should work fine, but would be good to test.
The text was updated successfully, but these errors were encountered: