speaking 🎙️

Dependency injection in React Native

- I have been selected to talk about dependency injection in a React Native context at the Mobilis in Mobile conference, here is the abstract and the replay.

Replacing part of your application should be as easy as replacing a piece of a Lego construction.

However, with time passing by and frameworks evolving, there are high chances to get locked in an overwhelming spaghetti of code, and struggle to untie the knots.

Books and wise code senseis taught us that the Inversion of Control, one of the SOLID design principle, is the key to get out of this mess.

Dependency Injection

Dependency Injection (DI) is a design pattern that implements the Inversion of Control.

Well established in Kotlin on Android, or in Swift on iOS, DI have been shadowed by React Native framework’s Context and Props concepts.

In the npm ecosystem, we are proposed libraries that offer efficient DI in React and React Native - the most famous being inversify. We’ll see how to use some of them in a livecode session and sums those up in a pros/cons table.

Benefits

In the second part of the livecode session, we will demonstrate our new benefits:

  • Breaking the app monolith into clear separated modules.
  • Testing your app with effective mocks.
  • Demo our features by injecting intelligent doubles where we miss an implementation 😍

And that’s a wrap. Replacing/rewriting part of our app is now as easy as if we handle Lego in our hands.

Watch

This talk was first given on June 20th 2023 in french 🇫🇷 🥐.

Conference @ Mobilis in Mobile