ionic-team / ionic-team/ionic-docs

content: Missing Event type when trying to subscribe to 'ionBackButton' with React.

Aperta
#4,261 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
content
Lingua principale
MDX
Stelle
621
Fork
3.2k
Merge medio
1g 2h
PR unite (30g)
86

Descrizione

### URL

https://ionicframework.com/docs/developing/hardware-back-button

### Issue Description

When trying to subscribe to `'ionBackButton'` the way it is written on the docs, the compiler complains about the property `detail` with the message: "`Property 'detail' does not exist on type 'Event'.ts(2339)`".

The current solution is to cast the `event` parameter to `any`. Other solutions have been tried, like casting to `BackButtonEvent` from `@ionic/react` or `@ionic/core`.

Image below is how I found the current solution on the Ionic discord:
Image

`npm ls`:
```
├── @capacitor-community/admob@7.0.3
├── @capacitor-community/keep-awake@7.1.0
├── @capacitor/android@7.4.2
├── @capacitor/app@7.0.1
├── @capacitor/assets@3.0.5
├── @capacitor/browser@7.0.2
├── @capacitor/cli@7.4.2
├── @capacitor/core@7.4.2
├── @capacitor/device@7.0.2
├── @capacitor/haptics@7.0.1
├── @capacitor/ios@7.4.2
├── @capacitor/keyboard@7.0.1
├── @capacitor/status-bar@7.0.1
├── @ionic/core@8.7.3
├── @ionic/react-router@8.7.1
├── @ionic/react@8.7.1
├── @testing-library/dom@10.4.1
├── @testing-library/jest-dom@5.17.0
├── @testing-library/react@16.3.0
├── @testing-library/user-event@14.6.1
├── @types/react-dom@19.0.4
├── @types/react-router-dom@5.3.3
├── @types/react-router@5.1.20
├── @types/react@19.0.10
├── @vitejs/plugin-legacy@7.2.1
├── @vitejs/plugin-react@4.7.0
├── cypress@13.17.0
├── eslint-plugin-react-hooks@5.2.0
├── eslint-plugin-react-refresh@0.4.20
├── eslint-plugin-react@7.37.5
├── eslint@9.32.0
├── globals@15.15.0
├── ionicons@7.4.0
├── jsdom@22.1.0
├── react-dom@19.0.0
├── react-router-dom@5.3.4
├── react-router@5.3.4
├── react@19.0.0
├── terser@5.43.1
├── typescript-eslint@8.38.0
├── typescript@5.8.3
├── vite@7.1.1
└── vitest@3.2.4
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.