-
-
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
How to lazyload a hook? #975
Comments
Look like a little gap in documentation. The result of any operation is a component. const Carousel = loadable.lib(() => import('../components/ui/Carousel'));
//...
<Carousel>{({useCarousel}) => useCarousel()....}</Carousel> If only |
Damn, that's a pity... Is there a feature request I can vote on for implementing this? |
This library is not really under active development and frankly speaking even not under very active maintenance. So unless someone steps in to implement a few feature it will be not implemented. At the same time this feature is "supported" by react-imported-component const MyComponent = () => {
// you can import whatever you want
const {
imported: useCarousel,
loadable: carouselLoadable
} = useImported(() => import('../components/ui/Carousel'),(components) => components.useCarousel );
// but in order to "obey" the rule of hooks you need to "break" this component
if(!useCarousel){
throw carouselLoadable.resolution;
}
// you can combine `useImported` and `throw` in a custom hook, but that would cause waterfalls
} |
💬 Questions and Help
I have a module that exports both a React Component and a hook to configure the component.
I tried:
But this failed the first time I tried calling
useCarousel
saying thatuseCarousel
is not a function.Any help would be appreciated.
The text was updated successfully, but these errors were encountered: