DEV Community

Discussion on: React Beginner Question Thread ⚛

Collapse
 
brundozer profile image
Bruno Arsene

Hi Dan !

I come from the angular world where we heavily use services and dependency injection. This makes the code easy to test by mocking dependencies. But when it comes to react, I cannot find a clean way to achieve the same. Is there a proper way to inject dependencies in your components ?

Thanks :)

Collapse
 
dan_abramov profile image
Dan Abramov

I tend to either use context for this, or something like jest.mock() (that is, if you use Jest).