mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 11:17:19 +08:00
fix(react): fix types for new stencil
This commit is contained in:
@ -2,10 +2,10 @@ import { JSX as LocalJSX } from '@ionic/core';
|
||||
import React from 'react';
|
||||
|
||||
import { NavContext } from '../../contexts/NavContext';
|
||||
import { ReactProps } from '../ReactProps';
|
||||
import { IonicReactProps } from '../IonicReactProps';
|
||||
import { IonBackButtonInner } from '../inner-proxies';
|
||||
|
||||
type Props = LocalJSX.IonBackButton & ReactProps & {
|
||||
type Props = LocalJSX.IonBackButton & IonicReactProps & {
|
||||
ref?: React.RefObject<HTMLIonBackButtonElement>;
|
||||
};
|
||||
|
||||
|
@ -6,10 +6,9 @@ import { IonTabBarInner } from '../inner-proxies';
|
||||
import { IonTabButton } from '../proxies';
|
||||
|
||||
type Props = LocalJSX.IonTabBar & {
|
||||
ref?: React.RefObject<HTMLIonTabBarElement>;
|
||||
navigate: (path: string, direction: 'back' | 'none') => void;
|
||||
currentPath: string;
|
||||
children?: React.ReactNode;
|
||||
navigate?: (path: string, direction: 'back' | 'none') => void;
|
||||
currentPath?: string;
|
||||
slot?: 'bottom' | 'top';
|
||||
};
|
||||
|
||||
interface Tab {
|
||||
@ -48,7 +47,7 @@ const IonTabBarUnwrapped = /*@__PURE__*/(() => class extends React.Component<Pro
|
||||
const activeTab = Object.keys(state.tabs)
|
||||
.find(key => {
|
||||
const href = state.tabs[key].originalHref;
|
||||
return props.currentPath.startsWith(href);
|
||||
return props.currentPath!.startsWith(href);
|
||||
});
|
||||
|
||||
if (activeTab === undefined || (activeTab === state.activeTab && state.tabs[activeTab].currentHref === props.currentPath)) {
|
||||
@ -68,10 +67,13 @@ const IonTabBarUnwrapped = /*@__PURE__*/(() => class extends React.Component<Pro
|
||||
}
|
||||
|
||||
private onTabButtonClick = (e: CustomEvent<{ href: string, selected: boolean, tab: string }>) => {
|
||||
if (this.state.activeTab === e.detail.tab) {
|
||||
this.props.navigate(this.state.tabs[e.detail.tab].originalHref, 'back');
|
||||
} else {
|
||||
this.props.navigate(this.state.tabs[e.detail.tab].currentHref, 'none');
|
||||
const { navigate } = this.props;
|
||||
if (navigate) {
|
||||
if (this.state.activeTab === e.detail.tab) {
|
||||
navigate(this.state.tabs[e.detail.tab].originalHref, 'back');
|
||||
} else {
|
||||
navigate(this.state.tabs[e.detail.tab].currentHref, 'none');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +98,7 @@ const IonTabBarUnwrapped = /*@__PURE__*/(() => class extends React.Component<Pro
|
||||
}
|
||||
})();
|
||||
|
||||
export const IonTabBar: React.FC<LocalJSX.IonTabBar & { currentPath?: string, navigate?: (path: string) => void; }> = props => {
|
||||
export const IonTabBar: React.FC<Props> = props => {
|
||||
const context = useContext(NavContext);
|
||||
return (
|
||||
<IonTabBarUnwrapped
|
||||
|
Reference in New Issue
Block a user