bug: [React 5.0.4] IonTabs - Using HTMLIonTabElement type for ref gives [TS 2322] error.
See original GitHub issueBug Report
Ionic version:
[x] 5.0.4
Current behavior:
Declaring a reference to tabs elements as HTMLIonTabsElement
and then using it on an IonTabs
element gives an error saying
Type 'RefObject<HTMLIonTabsElement>' is not assignable to type 'RefObject<IonTabs>'.
Expected behavior:
Should be able to create a ref using HTMLIonTabsElement
type and assign it to a Tabs element.
Steps to reproduce:
- Create a ref variable with type
HTMLIonTabsElement
. - Assign it to the Tabs element.
Related code:
let tabsRef = useRef<HTMLIonTabsElement>(null);
return (
<IonTabs ref={tabsRef}>
</IonTabs>
);
Other information:
Ionic info:
Ionic:
Ionic CLI : 6.1.0 (/Users/abc/.nvm/versions/node/v10.16.3/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/react 5.0.4
Capacitor:
Capacitor CLI : 1.4.0
@capacitor/core : 1.4.0
Utility:
cordova-res : not installed
native-run : not installed
System:
NodeJS : v10.16.3 (/Users/abc/.nvm/versions/node/v10.16.3/bin/node)
npm : 6.13.0
OS : macOS Catalina
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (6 by maintainers)
Top Results From Across the Web
React TypeScript Error : TS2322 - Type '' is not assignable to ...
I have a new .tsx file, and I wish pass the title to my component. However, the property "title" returns the following error...
Read more >Ion-Tabs: Tab-Based Component for App Top-Level Navigation
The component is a container of individual Tab components. The ion-tabs component does not have any styling and works as a router outlet...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the issue. I am going to close this as devs should use
IonTabsContext
instead ofHTMLIonTabsElement
. Certain components such as tabs needed to have special React wrappers in order to integrate with React Router, which is why this difference exists. We will look into making these sorts of things clearer in the documentation. Thank you!Yes, thank you! For a guide on how to create a pull request and test this project locally to see your changes, see our contributing documentation.
Please let me know if you have any questions.