drcmda / react-contextual

🚀 react-contextual is a small (less than 1KB) helper around React 16s new context api
MIT License
642 stars 23 forks source link

Subscriber component causes re-mount of children on prop changes #34

Open afrankel-sfdo opened 5 years ago

afrankel-sfdo commented 5 years ago

The subscriber HOC works fine, but the Component causes all children to re-mount on any prop changes.

contextual

See demo here: https://codesandbox.io/s/4jr86n2w77

Typing into Component text box loses focus on each keypress (due to re-mount), whereas the HOC works fine.

I suspect this is due to creating a new react element on each prop change here: https://github.com/drcmda/react-contextual/blob/master/src/subscribe.js#L73

afrankel-sfdo commented 5 years ago

@drcmda #bump. Is this project still being maintained? Do you welcome PRs?

smeijer commented 5 years ago

@afrankel-sfdo, PR's would be most welcome.

afrankel-sfdo commented 5 years ago

@smeijer I updated the code sandbox to better demonstrate the component remounting (HOC is fine) via console logs. Curious if you had any pointers for how to resolve before I dive in.

https://codesandbox.io/s/qkx5x5y5qj

mounting

afrankel-sfdo commented 5 years ago

@smeijer bump. Any guidance before I try to resolve this?

afrankel-sfdo commented 5 years ago

@smeijer ??