blitz-js / babel-plugin-superjson-next

Automatically transform your Next.js Pages to use SuperJSON
MIT License
124 stars 15 forks source link

Prevents loss of static methods #7

Closed ntgussoni closed 3 years ago

ntgussoni commented 3 years ago

I was testing this babel plugin in one of our projects with blitz.js and noticed that whenever the WithSuperJSON HOC was used, the getLayout method was lost (as well as other static methods).

The fix is pretty simple and referenced here https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over

This PR adds hoistNonReactStatics as recommended and a test in the examples folder.

Skn0tt commented 3 years ago

Love it! Thanks for this well-made PR ☺️

Skn0tt commented 3 years ago

@allcontributors add ntgussoni code test bug

allcontributors[bot] commented 3 years ago

@Skn0tt

I've put up a pull request to add @ntgussoni! :tada: