You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For any of the component types created with createControllerComponent or createOverlayComponent, the typing is such that you cannot pass them a ref. As an example, the following code:
Produces an error like this when compiled by Typescript:
Type 'RefObject<HTMLIonAlertElement>' is not assignable to type 'string|((instance: {overlay?: HTMLIonAlertElement|undefined;isUnmounted: boolean;componentDidMount(): Promise<void>;componentWillUnmount(): void; ... 8more ...;refs: { ...;};}|null)=>void)|RefObject<...>|null|undefined'.Type 'RefObject<HTMLIonAlertElement>' is not assignable to type 'RefObject<{overlay?: HTMLIonAlertElement|undefined;isUnmounted: boolean;componentDidMount(): Promise<void>;componentWillUnmount(): void;componentDidUpdate(prevProps: AlertOptions&ReactControllerProps): Promise<...>; ... 7more ...;refs: { ...;};}>'.Type 'HTMLIonAlertElement' is missing the following properties from type '{overlay?: HTMLIonAlertElement|undefined;isUnmounted: boolean;componentDidMount(): Promise<void>;componentWillUnmount(): void;componentDidUpdate(prevProps: AlertOptions&ReactControllerProps): Promise<...>; ... 7more ...;refs: { ...;};}': isUnmounted, componentDidMount, componentWillUnmount, componentDidUpdate, and 6 more. TS2322
Expected behavior:
These components should accept a ref.
The createOverlayComponent and createControllerComponent functions return the component class directly. I am definitely not an expert, but it seems like they should be changed to work the way createComponent does w.r.t. the ref.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Bug Report
Ionic version:
[x] 4.11.4
Current behavior:
For any of the component types created with
createControllerComponent
orcreateOverlayComponent
, the typing is such that you cannot pass them a ref. As an example, the following code:Produces an error like this when compiled by Typescript:
Expected behavior:
These components should accept a ref.
Steps to reproduce:
See the code above.
Related code:
The
createComponent
function is used to make most of the React components, and it returns the result of a call tocreateForwardRef
based on the class it has defined.The createOverlayComponent and createControllerComponent functions return the component class directly. I am definitely not an expert, but it seems like they should be changed to work the way
createComponent
does w.r.t. the ref.Other information:
Ionic info:
The text was updated successfully, but these errors were encountered: