-
-
Notifications
You must be signed in to change notification settings - Fork 380
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
Is it possible to fully dynamically load external package component ? #915
Comments
There is nothing special in loadable code capable to distinguish between your code and node_modules. However, I never tried loading stuff like in your example. Can I ask for clarification - what does mean "This guy doesnt work"? How exactly? |
Probably off-topic, but what I noticed is if you use this construction in a loop: const AsyncIcon = loadable(
// this import resolves only for the 1st icon in the list which is the component "A" (see below)
(props) => import(`./${props.icon}`),
{
resolveComponent(module, props) {
// here you'll receive the icon name from each `map` iteration ("A", then "B", and "C" in the last call)
const { icon } = props;
// in case the module doesn't use a `default` export you have to take it by its key.
// however, this will fail because the module is always "A", but on the second step you expect it as "ModuleB.B"
return module[icon];
},
}
); and then const icons = ["A", "B", "C"];
<>
{icons.map(icon => <AsyncIcon key={icon} icon={icon} /> }
</> I was able to "solve" it via |
A little off-topic, but |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I have the same problem. Dynamic path doesnt work, hardcoded one does. This works: const C = loadable(() => import('../screens/Test') This doesnt work: const componentPath = props.match.route.compPath // ../screens/Test
const C = loadable(() => import(`${componentPath}`)) It does not find the module... Webpack shows |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
We have a component library. We are trying to load a component with dynamic name. It doest work when i try to load it from node_modules, but it works when i try to load local files
This guy works
This guy doesnt work
So my question is, is it possible to load dynamically files from node_modules ?
(doing it in nextjs)
Also, to make clear, the problem is with dynamically constructed imports, this guy, works without problems:
The text was updated successfully, but these errors were encountered: