Closed JohannesConrad closed 2 months ago
Hi, I am working with single-spa-react in a project and recently updated from version 4.x to 6.0.1. With the Commit for React18 support there was a typing for loadRootComponent introduced that causes issues. The props?: RootComponentProps are now optional which makes a defined check necessary in some instances. https://github.com/single-spa/single-spa-react/blob/6c80e56d5084002e38ae215f41f796608dc49725/types/single-spa-react.d.ts#L29
props?: RootComponentProps
Digging into the code I found: https://github.com/single-spa/single-spa-react/blob/6c80e56d5084002e38ae215f41f796608dc49725/src/single-spa-react.js#L52 If I interpret that correctly it will fail if the props from above are undefined anyway.
I am not sure if there is something I missed and it's necessary for the props to be optional.
I expected the prop to look like:
loadRootComponent?: ( props: RootComponentProps ) => Promise<React.ElementType<RootComponentProps>>;
Thanks in advance for any feedback and have a lovely day Johannes 🐕
The two lines of you code that were linked are unrelated. The line that throws an error is related to the singleSpaReact function, not the loadRootComponent function
singleSpaReact
loadRootComponent
Hi, I am working with single-spa-react in a project and recently updated from version 4.x to 6.0.1. With the Commit for React18 support there was a typing for loadRootComponent introduced that causes issues. The
props?: RootComponentProps
are now optional which makes a defined check necessary in some instances. https://github.com/single-spa/single-spa-react/blob/6c80e56d5084002e38ae215f41f796608dc49725/types/single-spa-react.d.ts#L29Digging into the code I found: https://github.com/single-spa/single-spa-react/blob/6c80e56d5084002e38ae215f41f796608dc49725/src/single-spa-react.js#L52 If I interpret that correctly it will fail if the props from above are undefined anyway.
I am not sure if there is something I missed and it's necessary for the props to be optional.
I expected the prop to look like:
Thanks in advance for any feedback and have a lovely day Johannes 🐕