gaearon / react-deep-force-update

Force-updates React component tree recursively
MIT License
122 stars 19 forks source link

Update only elements that subscribe to given contextType #3

Closed wmertens closed 7 years ago

wmertens commented 7 years ago

I use this to update components that use context to get translation strings after the language was switched.

I know this uses internal APIs, but using this is much nicer than either constantly managing 100+ listeners or force-rerendering the app through a key on the root element.

It would be even nicer if it would only update components that use the context in the first place. Would that be difficult to do? Would you accept a PR that does this?

iddan commented 7 years ago

Exact use case

gregberge commented 7 years ago

Fixed by #6

gregberge commented 7 years ago

Fixed by #6

wmertens commented 7 years ago

@neoziro wouldn't it be nicer to provide a reference implementation of the shouldUpdate function for contextName-only updates?

gaearon commented 7 years ago

I was about to write an implementation but then realized there is a problem with #6. I filed https://github.com/gaearon/react-deep-force-update/issues/8 for it.