Giter VIP home page Giter VIP logo

Comments (3)

theKashey avatar theKashey commented on May 28, 2024

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.

ion-willo avatar ion-willo commented on May 28, 2024

Damn, that's a pity...

Is there a feature request I can vote on for implementing this?

from loadable-components.

theKashey avatar theKashey commented on May 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.