I've been making considerable progress with react.di, although I've just spent an hour to finally figure out that property injection for services doesn't seem to work.
Is there a way to enable this? If not already, do you plan to support it? It seems like a logical and convenient setup for a service.
[15:21:23.904] [error] Error: Component "Commander" need to be nested in a Module or Provider Component to use dependency injection.
at checkIfContainerExists (node_modules\react.di\lib\component-injection.js:30:15)
After I converted it to constructor injection I got it to work:
@Injectable
export class Commander implements ICommander {
log!: ILog;
constructor(
@Inject("ILog") // For some reason these can't be injected as properties with services!
log: ILog
) {
this.log = log;
}
// ...
}
I've been making considerable progress with react.di, although I've just spent an hour to finally figure out that property injection for services doesn't seem to work.
Is there a way to enable this? If not already, do you plan to support it? It seems like a logical and convenient setup for a service.
Example of the problem follows...
I was trying to do this:
Then I was getting this error:
After I converted it to constructor injection I got it to work:
Thanks! Ash