Reactjs 爱奥尼亚+;使用ionic hardware back按钮关闭Cupertino窗格或任何第三方覆盖或模式
我使用一个名为的库,我想使用hardware backbutton关闭窗格,但它不起作用。我把窗格做成了一个我称之为IonDrawer的组件 我试过:Reactjs 爱奥尼亚+;使用ionic hardware back按钮关闭Cupertino窗格或任何第三方覆盖或模式,reactjs,ionic-framework,Reactjs,Ionic Framework,我使用一个名为的库,我想使用hardware backbutton关闭窗格,但它不起作用。我把窗格做成了一个我称之为IonDrawer的组件 我试过: // Trying to get access to the backButton in the Component useEffect(() => { if (Capacitor.isNative) { App.addListener("backButton", (ev: any) =&
// Trying to get access to the backButton in the Component
useEffect(() => {
if (Capacitor.isNative) {
App.addListener("backButton", (ev: any) => {
ev.detail.register(100, async () => {
hidePanel();
// this is a hack that made the page stays by not navigating to the previous route.
history.push(getPath);
});
});
}
});
const hidePanel = async () => {
console.log("Tapped");
isShowing.current = false;
await drawerRef.current?.destroy({ animate: true });
};