Is it okay to have multiple withTracker calls?


At the moment our app has a single call to withTracker at the App component.

This means we have a lot of ‘prop drilling’. I would like to change this but a colleague has told me that multiple withTracker calls within an app can cause problems.

Is this true, or a misconception?

1 Like

no, that does not cause problems. But its good to understand how withTracker works


If you are using at least React 16.3, you can use the new Context API to avoid prop drilling

1 Like

That’s not a problem in practice - I do use model built around the new Context API these days, but I’ve got a couple of apps that use withTracker all the over the place. I actually like to abstract those out into a pattern I call “connectors” - these are basically the first half of the container pattern, without wrapping a component. Then I can use the same “connector” to wrap multiple components to make multiple containers - each mounted component then has it’s own data source (with Context API it’s slightly more optimized, but that’s just an optimization, and isn’t necessary - and the pattern works just fine with dozens of instances)

1 Like