fix(react): IonNav works with react (#25565)

Resolves #24002 

Co-authored-by: Liam DeBeasi <liamdebeasi@icloud.com>
This commit is contained in:
Sean Perkins
2022-07-06 13:45:30 -04:00
committed by GitHub
parent ffb0311236
commit 420f9bbebd
9 changed files with 197 additions and 1 deletions

View File

@ -21,7 +21,15 @@ export const IonBackButton = /*@__PURE__*/ (() =>
context!: React.ContextType<typeof NavContext>;
clickButton = (e: React.MouseEvent) => {
/**
* If ion-back-button is being used inside
* of ion-nav then we should not interact with
* the router.
*/
if (e.target && (e.target as HTMLElement).closest('ion-nav') !== null) { return; }
const { defaultHref, routerAnimation } = this.props;
if (this.context.hasIonicRouter()) {
e.stopPropagation();
this.context.goBack(defaultHref, routerAnimation);