loadable-components and refs?

Created on 29 Jul 2018  ·  11Comments  ·  Source: gregberge/loadable-components

As it stands loadable-components doesn't handle refs (correct me if I'm wrong). Are there any plans to? My intended use case is to delay-load a component that needs a ref, and I don't really care about the ref until after it's loaded. (ie. I only care about the underlying component's ref, not the ref of the loadable or the loading component).

Most helpful comment

Yes it actually doesn't handle refs but it is on feature list.

All 11 comments

Yes it actually doesn't handle refs but it is on feature list.

Would it be a lot of work to add? AFAICT would it just be adding ref forwarding ala React manual (https://reactjs.org/docs/forwarding-refs.html)? I'm not sure how server-side rendering would factor into this though.

No it should be pretty simple to add. I think forwarding ref is the best thing to do. Even if it is not compatible with React <16, it is OK for me. But we have to be careful of compatibility, OK to not support refs in React <16 but not OK to drop support of React <16.

+1

+1

+1

Refs are not supported in v3 but I plan to add support soon. Feel free to open a new issue. I close it because this one was about v2.

@neoziro is this supported now? It seems like it is from the code and trying it out.

Yes refs are supported out of the box in v5, you can transparently use them.

Yes refs are supported out of the box in v5, you can transparently use them.

hey,how can i use refs?I use a ref to loadable compents, but get 'null';

Yes refs are supported out of the box in v5, you can transparently use them.

hey,how can i use refs?I use a ref to loadable compents, but get 'null';

For others that need this, you can use loadable.lib instead of loadable. See https://loadable-components.com/docs/library-splitting/.

Was this page helpful?
0 / 5 - 0 ratings