question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: [React 5.0.4] IonTabs - Using HTMLIonTabElement type for ref gives [TS 2322] error.

See original GitHub issue

Bug 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:

  1. Create a ref variable with type HTMLIonTabsElement.
  2. 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
liamdebeasicommented, Oct 7, 2021

Thanks for the issue. I am going to close this as devs should use IonTabsContext instead of HTMLIonTabsElement. 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!

1reaction
liamdebeasicommented, May 26, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found