3 ms·
Dependency injection in modern programming is known as "partial function application" and the poster you're replying to is correct. React Context is not at all
by zarathustreal 5y ago
Dependency injection in modern programming is known as "partial function application" and the poster you're replying to is correct. React Context is not at all an elegant solution, it's the opposite. It's a hard coupling to hidden global state.
- eliseumds 5y agoIt's not about loose or tight coupling, it's about things that React Context enables you do to. You're literally also hiding contextual data when using a partially-applied singleton, and you end up with code that is not safe when writing an event-looped single-threaded application (any NodeJS server implementation). Users cannot use react-helmet when doing stream-rendering, for example, because it's a singleton. See https://news.ycombinator.com/item?id=27032394 https://news.ycombinator.com/item?id=27032394.