Skip to content
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

loadable-components and refs? #108

Closed
linkenneth opened this issue Jul 29, 2018 · 11 comments
Closed

loadable-components and refs? #108

linkenneth opened this issue Jul 29, 2018 · 11 comments

Comments

@linkenneth
Copy link

linkenneth commented Jul 29, 2018

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).

@gregberge
Copy link
Owner

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

@linkenneth
Copy link
Author

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.

@gregberge
Copy link
Owner

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.

@themojilla
Copy link

+1

2 similar comments
@StefanoVuerich
Copy link

+1

@TrueMoein
Copy link

+1

@gregberge
Copy link
Owner

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.

@linkenneth
Copy link
Author

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

@gregberge
Copy link
Owner

gregberge commented Dec 11, 2018

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

@JiamaZhao
Copy link

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';

@silviubogan
Copy link

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/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants