I have a specific use-case where I need to trigger a modal to open by clicking a tab from the tab bar. Similar to how Instagram triggers a modal to open when clicking the (+) icon in the tab bar to add a new post.
Given the following Ionic React tabs set up, how should I reconfigure to make this work? I would very much like to avoid having to copy/paste my modal code on to every single page.
App.tsx
const App: React.FC = () => {
return (
<IonApp>
<IonReactRouter>
<IonTabs>
<IonRouterOutlet>
<Route path="/signup" component={SignUp} exact={true} />
<Route path="/login" component={Login} exact={true} />
<Route path="/home" component={Home} />
<Redirect exact from="/" to="/home" />
</IonRouterOutlet>
<IonTabBar slot="bottom">
<IonTabButton tab="home" href="/home">
<IonIcon icon={triangle} />
<IonLabel>Explore</IonLabel>
</IonTabButton>
<IonTabButton tab="submit" href="/submit">
<IonIcon icon={addCircle} />
<IonLabel>Submit</IonLabel>
</IonTabButton>
<IonTabButton tab="login" href="/login">
<IonIcon icon={square} />
<IonLabel>Log In</IonLabel>
</IonTabButton>
</IonTabBar>
</IonTabs>
</IonReactRouter>
</IonApp>
);
};
Where should I insert the following so that I can trigger this from the tab bar and have it overlay the page content regardless of what tab I am in?
<IonModal isOpen={showModal}>
<p>This is modal content</p>
<IonButton onClick={() => setShowModal(false)}>Close Modal</IonButton>
</IonModal>