FormidableLabs / react-ssr-prepass

A custom partial React SSR renderer for prefetching and suspense
MIT License
592 stars 26 forks source link

Potential bug with wrapped components? #79

Open tomkelsey opened 2 years ago

tomkelsey commented 2 years ago

Hi,

Using:

react-redux 7.2.6
react-router-dom 5.3.0
react-ssr-prepass 1.4.0

I've found if I export a component, "ComponentA" as:

withRouter(connect()(ComponentA)

I was getting the error:

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

which appeared to originate from react-ssr-prepass.

I can "fix" this in my code by wrapping ComponentA differently:

connect()(withRouter(ComponentA))

I haven't got the capacity or knowledge to look into this further at the moment but wanted to highlight it in case it is an underlying bug that perhaps impacts others? (Apologies if this is just some weird quirk unique to my code!)

I did see an issue I thought might be related in the why-did-you-render repo - https://github.com/welldone-software/why-did-you-render/issues/121

Where the fix appeared to be tweaking the order of the react component checks - https://github.com/welldone-software/why-did-you-render/commit/983a18fd72a61c02859c6c44d9eebe95a07ab3a3