Difference between injectDeps and useDeps, react-simple-di?


Could you please explain the difference? :blush:

As I understood when we use injectDeps we pass several objects as parameters AND when we use useDeps we pass func that returns object.

injectDeps uses React’s context feature to give every component used inside access to your apps actions & context objects. (hence why it’s used on your layout component)

It’s also the part that binds all your actions so that they all have the context as the first argument.

useDeps makes it so that you don’t have to use the context feature (which is currently experimental) directly in your component, instead providing the keys you specify as props.

The source is actually fairly simple: https://github.com/kadirahq/react-simple-di/blob/master/lib/index.js


Thank you a lot. Start reading src :slight_smile: You saved me second time)

1 Like