Files
owl/src/refs.ts
T
Samuel Degueldre c03042b44d [IMP] qweb/components: remove t-ref on components
Refs to component expose a lot of implementation details that should be
private to parents. Parent to child communication should go through
props.
2022-02-11 10:41:18 +01:00

19 lines
557 B
TypeScript

// -----------------------------------------------------------------------------
// useRef
// -----------------------------------------------------------------------------
import { getCurrent } from "./component/component_node";
/**
* The purpose of this hook is to allow components to get a reference to a sub
* html node or component.
*/
export function useRef<T extends HTMLElement = HTMLElement>(name: string): { el: T | null } {
const node = getCurrent()!;
return {
get el(): T | null {
return node.refs[name] || null;
},
};
}