Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency Injection using .defaultProps #16

Open
topa opened this issue Nov 10, 2016 · 1 comment
Open

Dependency Injection using .defaultProps #16

topa opened this issue Nov 10, 2016 · 1 comment

Comments

@topa
Copy link

topa commented Nov 10, 2016

I've created a gist that shows how DI could be solved for cases using only React features: https://gist.github.com/topa/efd6b170e18bda579aa751c5164f9211.

Do you think this could be also a valid approach?

This won't work with isomorphic apps as you'll have to initialize .getAppLocale() while bootstrapping the app either on server (e.g. in express Apps req.locale ) as on client (using window.navigator).

@topa topa changed the title Dependency Injection using .initialProps Dependency Injection using .defaultProps Nov 10, 2016
@krasimir
Copy link
Owner

krasimir commented Jun 3, 2018

I have no idea how I missed that issue. It's really weird. Sorry.

So, I think the idea is interesting but we kind of having the same problem. It is nice approach for delivering something to a component but I think the main problem is not in how we'll send the dependencies as props but how these dependencies reach the file of the component. What you are showing is I believe DI done via the module system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants