Skip to content

docs(react,angular): use ionPage prop for nested outlets and add navigation playgrounds#4454

Open
ShaneK wants to merge 15 commits intomajor-9.0from
v9/react-router-2183
Open

docs(react,angular): use ionPage prop for nested outlets and add navigation playgrounds#4454
ShaneK wants to merge 15 commits intomajor-9.0from
v9/react-router-2183

Conversation

@ShaneK
Copy link
Copy Markdown
Member

@ShaneK ShaneK commented Mar 30, 2026

Resolves #2183

Description

Currently, several examples for using React Router are incorrectly showing wrapping IonRouter with IonPage instead of using the ionPage prop. Additionally, React and Angular have hard-coded links to StackBlitz that we do not control and have since moved away from in favor of playgrounds.

This PR does multiple things:

  • Fixes React Router demonstrations
  • Removes direct extremely outdated StackBlitz "Live Examples" in favor of Playgrounds

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation

Examples

Angular Navigation/Routing - Live Example

React Navigation/Routing - Should no longer have IonPage wrapping IonRouter and should use the ionPage prop instead. Additionally, stackblitz link under Live Example swapped for Playground

@ShaneK ShaneK requested a review from a team as a code owner March 30, 2026 12:22
@ShaneK ShaneK requested review from brandyscarney and removed request for a team March 30, 2026 12:22
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ionic-docs Ready Ready Preview, Comment Mar 31, 2026 0:31am

Request Review

## Live Example

If you would prefer to get hands on with the concepts and code described above, please checkout our [live example](https://stackblitz.com/edit/ionic-angular-routing?file=src/app/app-routing.module.ts) of the topics above on StackBlitz.
<NavigationPlayground />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<NavigationPlayground />
import NavigationPlayground from '@site/static/usage/v9/angular/navigation/index.md';
<NavigationPlayground />

We normally import the playgrounds right before they're used:

import Multiple from '@site/static/usage/v8/accordion/multiple/index.md';
<Multiple />

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done as part of my move to a unified Playground (spread across two commits, linked in a reply to another comment)

---

import useBaseUrl from '@docusaurus/useBaseUrl';
import NavigationPlayground from '@site/static/usage/v9/angular/navigation/index.md';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import NavigationPlayground from '@site/static/usage/v9/angular/navigation/index.md';

See my first comment lower in this file

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done as part of my move to a unified Playground (spread across two commits, linked in a reply to another comment)

## Live Example

If you would prefer to get hands on with the concepts and code described above, please checkout our [live example](https://stackblitz.com/edit/ionic-react-routing?file=src/index.tsx) of the topics above on StackBlitz.
<NavigationPlayground />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<NavigationPlayground />
import NavigationPlayground from '@site/static/usage/v9/react/navigation/index.md';
<NavigationPlayground />

We normally import the playgrounds right before they're used:

import Multiple from '@site/static/usage/v8/accordion/multiple/index.md';
<Multiple />

Copy link
Copy Markdown
Member Author

@ShaneK ShaneK Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done as part of my move to a unified Playground (spread across two commits, linked in a reply to another comment)

---

import useBaseUrl from '@docusaurus/useBaseUrl';
import NavigationPlayground from '@site/static/usage/v9/react/navigation/index.md';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import NavigationPlayground from '@site/static/usage/v9/react/navigation/index.md';

See my first comment lower in this file

Copy link
Copy Markdown
Member Author

@ShaneK ShaneK Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done as part of my move to a unified Playground (spread across two commits, linked in a reply to another comment)

Comment on lines +35 to +36
size="large"
includeIonContent={false}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
size="large"
includeIonContent={false}
includeIonContent={false}
devicePreview={true}

Can we put this inside a device preview so it looks a bit nicer?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know how to do this before, thanks! This was done as part of my move to a unified Playground

Comment on lines +21 to +22
size="large"
includeIonContent={false}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
size="large"
includeIonContent={false}
includeIonContent={false}
devicePreview={true}

Can we put this inside a device preview so it looks a bit nicer?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know how to do this before, thanks! This was done as part of my move to a unified Playground

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than putting these under separate angular and react folders should we do one playground with both frameworks? Structure:

static
└── usage
    └── v9
        └── navigation
            ├── angular
            │   ├── app_component_html.md
            │   ├── app_component_ts.md
            │   ├── app_routes_ts.md
            │   ├── dashboard_page_component_html.md
            │   ├── dashboard_page_component_ts.md
            │   ├── example_component_html.md
            │   ├── example_component_ts.md
            │   ├── item_detail_page_component_html.md
            │   ├── item_detail_page_component_ts.md
            │   ├── settings_page_component_html.md
            │   └── settings_page_component_ts.md
            ├── react
            │   ├── dashboard_page_tsx.md
            │   ├── item_detail_page_tsx.md
            │   ├── main_tsx.md
            │   └── settings_page_tsx.md    
            ├── demo.html
            └── index.md

This would allow us to add a JavaScript and Vue one if we would like.

Copy link
Copy Markdown
Member Author

@ShaneK ShaneK Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the reason was we couldn't previously is because then the React playground would show the Angular playground by default (unless you happened to have selected React from a component view before, in which case Angular would have shown React by default), which is a bad UX.

This inspired me to fix this, though, so in this commit (de72886) I added support for default frameworks and made the React and Angular pages use it, most of the work for combining them was done in this commit though (58873e4)

);
};
const DashboardPage: React.FC = () => (
<IonRouterOutlet ionPage>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why ionPage is now required. We have never recommended adding this as a property and it is not added to any of the playgrounds.

Copy link
Copy Markdown
Member Author

@ShaneK ShaneK Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's never been recommended because the docs have been known to be wrongly recommending wrapping IonRouterOutlet in IonPages for several years and nobody has fixed it (note the age of the issue this resolves).

Using the ionPage prop on the router outlet directly benefits mostly nested routes (it's required by them, technically). When you have an outlet containing routes and one of those routes renders another outlet, like in a tab layout, the inner outlet needs to know about and be able to participate in the outer outlet's page transitions. Setting the prop makes the inner outlet itself the animatable page element, so the outer StackManager can transition it properly.

It's generally best to do this everywhere so you don't have to remember to do it in the special nested routing edge cases, and that will also be the case in RR6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants