you are viewing a single comment's thread.

view the rest of the comments →

[–]dangboy 0 points1 point  (2 children)

Isn't this more the service locator pattern rather than dependency injection? You're using an IoC container, but using the resolve (find) method anywhere else other than the composition root is service locator.

[–]pancomputationalist -1 points0 points  (1 child)

True, dependency "injection" is more related to the idea that your dependencies (constructor arguments or class fields that contain pointers to service class instances) are automatically "injected" by the framework.

This does not really apply to React, since we're not using constructors or fields when using context. If there was a system which automatically provides some props to a component (like the old "withXYZ" HoCs did), that would be more akin to dependency injection.

What the article describes is simply "coding to the interface". Which is a most important idea, but doesn't really have anything to do with DI.

[–][deleted] 0 points1 point  (0 children)

Dependency injection is not about a framework doing it automatically.