clean-architecture-react
clean-architecture-react copied to clipboard
Feat/react context for di
trafficstars
Using React Context to Dependencie Injection
Inside the Services folder we've got all set up for react context, provider and hook, there will be our entry point to inject new dependencies or replace.
An interesting point: If I needed to change a dependency to a specific use case? How would be? Since we're injecting the dependency to use for all useCase throughout our code base.
Anserw: Whenever you retrieve a context, the React's algoritm will reach to the CLOSEST provider available on the tree, that's it!
Need a specific dependencies for a use case? Just create another provider replacing the services for that specific use case!
P.S: this approach will replace the Implementations classes