-
-
Notifications
You must be signed in to change notification settings - Fork 383
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
Error when working with snapshots #25
Comments
I'm a little perplexed, since I can't understand how the components object in componentTracker.js could ever be populated when loadComponents is called. The hydration of the app itself comes after loadComponents is complete, so the app can't have populated the component cache yet. So, when calling loadComponents, the components object will always be empty. I'm pretty sure I'm doing something wrong. :) |
const snapSaveState = () => {
document.querySelector('html').setAttribute(
'data-snap-state',
JSON.stringify(getState())
);
}; not sure where you got this snippet from. Use exact code from readme: window.snapSaveState = () => getState(); UPD:
I missed that part |
The current version of loadable-components has some issues with registering. I have to rewrite that part to handle all cases. |
This issue should be solved in v1. You should give a try, feel free to open a new issue if you experienced any problem. |
I'm using a tool similar to react-snap, and can verify that I'm setting
window.__LOADABLE_COMPONENT_IDS__ = [2]
.Then, as specified in the react-snap docs, I'm doing the following:
However, loadComponent throws the following error:
The problem is here, since
componentTracker.get(id)
is undefined.I set breakpoints in componentTracker, and found that the
components
object incomponentTracker.js
is just an empty object. This is expected - loadComponent is the first thing to get called.This is what my index.js looks like:
I'm using a data-attribute on the HTML tag instead of setting an inline script tag because of CSP limitations. However, in essence, this shouldn't change anything, since I've made the correct global available before calling loadComponents.
Am I doing something wrong?
The text was updated successfully, but these errors were encountered: