-
Notifications
You must be signed in to change notification settings - Fork 62
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
Typescript, react-redux and asyncComponent usage? #62
Comments
Got it finally. If I change the definition for resolve to return a React.ReactNode like this:
and then pass the Own Props definition into the asyncComponent call:
it starts working. |
I think this is due to the
It keep the compiler happy so it doesn't think you're trying to do anything silly. The advantage with using Edit: I gave another look over your mods to the type definition and see that with your change to the resolve method you would still gain the ability to get prop checks/suggestions (if you explicitly provide your props Type) when importing the async component, while sacrificing the ability to properly type check the resolve callback itself. This would allow interoperability with the |
Ah, thank you - that works. I'll close my pull request, and put in a different one to update the docs with a typescript usage example instead :) |
@dawnmist - legend thank you for that! |
Hi,
I'm trying to use asyncComponent to load react-redux connected components for code splitting, but I'm having trouble with the asyncComponent Configuration's resolve typescript definitions. I'm not sure if I'm doing something wrong, or if there is an incompatibility between the return type of react-redux's connect and the resolve return type.
Very cut-down component setup example:
'./components/Page.tsx':
'./containters/PageContainer.tsx:
'./App.tsx':
Hopefully I haven't made any critical typos in the example.
What I am getting is Typescript is rejecting the AsyncPage's resolve function.
Message is:
What do I need to provide by the way of type information to asyncComponent/Configuration to be able to use this with a connected component?
The text was updated successfully, but these errors were encountered: