Comments (3)
Look like a little gap in documentation. The result of any operation is a component.
loadable.lib
is render prop pattern giving you access to any function "dynamically". Stil you cannot use it as you might want.
const Carousel = loadable.lib(() => import('../components/ui/Carousel'));
//...
<Carousel>{({useCarousel}) => useCarousel()....}</Carousel>
If only loadable.lib
had a hook form π
from loadable-components.
Damn, that's a pity...
Is there a feature request I can vote on for implementing this?
from loadable-components.
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
"supported" because you our will get fancy API and waterfall requests, or not fancy code you might have to "micromanage". There is no preexisting example for "hooks", let me provide one here
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
}
from loadable-components.
Related Issues (20)
- Support async-node and Module Federation HOT 5
- Thread loading of undefined as loading error HOT 1
- Preparing users for new lazy component HOT 4
- Add importEntrypoint to CunkExtractor and donβt load stats with require. HOT 9
- Hydration is not working sometimes on some pages HOT 7
- How use it express ssr + react-scripts. How create this file? '../dist/loadable-stats.json' HOT 1
- Loadable not accepting react-p5-wrapper as input HOT 7
- Component types are incompatible with React 18 HOT 2
- Loadable component SSR remote (localhost:port) HOT 2
- lazy typescript definition missing options argument: Expected 1 argument, but got 2 HOT 2
- Can't get `fallback` to display component HOT 3
- What is the best way to prevent failure to load component or catch properly? HOT 7
- getting Uncaught TypeError: Failed to resolve module specifier HOT 1
- loadable/component Synchronously Load Component Failed with Error "Cannot convert undefined or null to object HOT 2
- SassError: Undefined variable HOT 1
- Inline Chunk injection HOT 2
- Not working with latest @loadable/server & @loadable/babel-plugin `v5.16.0` version HOT 4
- Fallback behaviour HOT 1
- Main.js is rendered on every page even if I splitted each page into chunks with @loadable/component
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from loadable-components.