Slight gotcha when upgrading
AshMcConnell opened this issue · 3 comments
Hi Folks,
I upgraded from "ngx-take-until-destroy": "^5.4.0"
and ran the upgrade script. It worked great, but there is a slight issue that I came across.
If you have a providers that reference the class being defined you must use forwardRef.
e.g. this must change
providers: [
{provide: NG_VALUE_ACCESSOR, useExisting: SomeComponent, multi: true}
]
})
export class SomeComponent
to this: -
providers: [
{provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => SomeComponent), multi: true},
]
})
export class SomeComponent
It might help someone to mention it in the docs? Or perhaps I just didn't know enough about how forwardRef works.
Maybe I'm missing something but how is it related to this package? :)
Ha, sorry, I might have the wrong end of the stick, but I'm pretty sure when my component is decorated with @UntilDestroy()
it must use forwardRef whereas it was working without the forwardRef before.
I'll hunt out the error I was getting when I get back to work on Monday if it's useful
I'm closing the issue. If you have any additional information, feel free to re-open it.