Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Adds support for Context #64

Closed
wants to merge 4 commits into from
Closed

Conversation

srikrsna
Copy link

@srikrsna srikrsna commented Sep 5, 2019

I was just curious if this would make for a good helper. With context you can inject arbitrary values in the dom tree.

This can also be used to inject the redux store with the added ability to mock the store rather than use a global.

I use it for passing in loggers's, user's authentication details and other things that are present across the entire app. This is essentially dependency injection for web components.

I haven't added any tests yet but tested out manually with an example and this is working.

@jamesfulford
Copy link

I've found that associating DI directly with the DOM works great for view-layer code. However, the moment you want to inject dependencies into data-layer code (like injecting an http-client into a Redux thunk), the DOM method usually suffers. This argument applies to React Context and its coupling with Virtual DOM, too. I credit Angular for thinking about DI for service code as well as components.

I've gone with variations of the globals approach, for what it's worth.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3 participants