MicheleBertoli / react-automata

A state machine abstraction for React
MIT License
1.34k stars 60 forks source link

Fix: Hoist statics from child in `withStateMachine` HOC #76

Closed FiberJW closed 6 years ago

FiberJW commented 6 years ago

The withStateMachine HOC function returns a component that doesn't inherit its child component's static properties. This becomes a problem when using libraries like React Navigation and others that depend on their users implementing static properties for customization. Here's a link to the React docs about the importance of lifting the static properties when creating a HOC: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over. I ran yarn test, and the tests seem to pass with these changes.

screen shot 2018-10-01 at 3 24 29 pm

Thanks for your time!

MicheleBertoli commented 6 years ago

Nice, thank you very much for your PR, @FiberJW.