[IMP] hooks: improve useRef typings

With this commit, we can get the type for the target component for a
ref.

By default, if the generic type is not given, the ref will simply use
the base Component type.
This commit is contained in:
Géry Debongnie
2020-04-30 15:58:29 +02:00
committed by aab-odoo
parent 559fadb62a
commit b8d3618afa
2 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -267,7 +267,7 @@ describe("hooks", () => {
class WidgetC extends Component {
static template = xml`<div class="outer-div">Hello<WidgetB t-ref="mywidgetb" /></div>`;
static components = { WidgetB };
ref = useRef("mywidgetb");
ref = useRef<WidgetB>("mywidgetb");
}
const widget = new WidgetC();