Skip to content

Commit f6a2c1c

Browse files
committed
docs(react): update quickstart to include file names and start file paths from root
1 parent 5f8ef03 commit f6a2c1c

File tree

3 files changed

+99
-96
lines changed

3 files changed

+99
-96
lines changed

docs/react/quickstart.md

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -53,30 +53,31 @@ After running `ionic serve`, your project will open in the browser.
5353

5454
## Explore the Project Structure
5555

56-
Your new app's `src` directory will look like this:
56+
Your new app's directory will look like this:
5757

5858
```shell
59-
├── App.tsx
60-
├── components
61-
│   ├── ExploreContainer.css
62-
│   └── ExploreContainer.tsx
63-
├── main.tsx
64-
└── pages
65-
   ├── Home.css
66-
   └── Home.tsx
59+
└── src/
60+
├── App.tsx
61+
├── components
62+
│ ├── ExploreContainer.css
63+
│ └── ExploreContainer.tsx
64+
├── main.tsx
65+
└── pages
66+
├── Home.css
67+
└── Home.tsx
6768
```
6869

6970
:::info
70-
All file paths in the examples below are relative to the `src/` directory.
71+
All file paths in the examples below are relative to the project root directory.
7172
:::
7273

7374
Let's walk through these files to understand the app's structure.
7475

7576
## View the App Component
7677

77-
The root of your app is defined in `App.tsx`:
78+
The root of your app is defined in `src/App.tsx`:
7879

79-
```tsx
80+
```tsx title="src/App.tsx"
8081
import { Redirect, Route } from 'react-router-dom';
8182
import { IonApp, IonRouterOutlet, setupIonicReact } from '@ionic/react';
8283
import { IonReactRouter } from '@ionic/react-router';
@@ -108,9 +109,9 @@ This sets up the root of your application, using Ionic's `IonApp` and `IonReactR
108109

109110
## View Routes
110111

111-
Routes are defined within the `IonRouterOutlet` in `App.tsx`:
112+
Routes are defined within the `IonRouterOutlet` in `src/App.tsx`:
112113

113-
```tsx
114+
```tsx title="src/App.tsx"
114115
<IonRouterOutlet>
115116
<Route exact path="/home">
116117
<Home />
@@ -125,9 +126,9 @@ When you visit the root URL (`/`), the `Home` component will be loaded.
125126

126127
## View the Home Page
127128

128-
The Home page component, defined in `pages/Home.tsx`, imports the Ionic components and defines the page template:
129+
The Home page component, defined in `src/pages/Home.tsx`, imports the Ionic components and defines the page template:
129130

130-
```tsx
131+
```tsx title="src/pages/Home.tsx"
131132
import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/react';
132133
import ExploreContainer from '../components/ExploreContainer';
133134
import './Home.css';
@@ -163,9 +164,9 @@ For detailed information about Ionic layout components, see the [Header](/docs/a
163164

164165
## Add an Ionic Component
165166

166-
You can enhance your Home page with more Ionic UI components. For example, import and add a [Button](/docs/api/button) at the end of the `IonContent` in `pages/Home.tsx`:
167+
You can enhance your Home page with more Ionic UI components. For example, import and add a [Button](/docs/api/button) at the end of the `IonContent` in `src/pages/Home.tsx`:
167168

168-
```tsx
169+
```tsx title="src/pages/Home.tsx"
169170
import { IonButton, IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/react';
170171
// ...existing imports...
171172

@@ -191,9 +192,9 @@ export default Home;
191192

192193
## Add a New Page
193194

194-
Create a new page at `pages/New.tsx`:
195+
Create a new page at `src/pages/New.tsx`:
195196

196-
```tsx
197+
```tsx title="src/pages/New.tsx"
197198
import { IonBackButton, IonButtons, IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/react';
198199

199200
const New: React.FC = () => {
@@ -223,21 +224,21 @@ export default New;
223224

224225
This creates a page with a [Back Button](/docs/api/back-button) in the [Toolbar](/docs/api/toolbar). The back button will automatically handle navigation back to the previous page, or to `/` if there is no history.
225226

226-
:::warning Important
227+
:::warning
227228
When creating your own pages, always use `IonPage` as the root component. This is essential for proper transitions between pages, base CSS styling that Ionic components depend on, and consistent layout behavior across your app.
228229
:::
229230

230231
## Navigate to the New Page
231232

232-
To navigate to the new page, create a route for it by first importing it at the top of `App.tsx` after the `Home` import:
233+
To navigate to the new page, create a route for it by first importing it at the top of `src/App.tsx` after the `Home` import:
233234

234-
```tsx
235+
```tsx title="src/App.tsx"
235236
import New from './pages/New';
236237
```
237238

238239
Then, add its route in `IonRouterOutlet`:
239240

240-
```tsx
241+
```tsx title="src/App.tsx"
241242
<IonRouterOutlet>
242243
<Route exact path="/home">
243244
<Home />
@@ -251,9 +252,9 @@ Then, add its route in `IonRouterOutlet`:
251252
</IonRouterOutlet>
252253
```
253254

254-
Once that is done, update the button in `pages/Home.tsx`:
255+
Once that is done, update the button in `src/pages/Home.tsx`:
255256

256-
```tsx
257+
```tsx title="src/pages/Home.tsx"
257258
<IonButton routerLink="/new">Navigate</IonButton>
258259
```
259260

@@ -265,16 +266,16 @@ Navigating can also be performed programmatically using React Router's `history`
265266

266267
Ionic React comes with [Ionicons](https://ionic.io/ionicons/) pre-installed. You can use any icon by setting the `icon` property of the `IonIcon` component.
267268

268-
Update the imports in `pages/New.tsx` to import `IonIcon` and the `heart` and `logoIonic` icons:
269+
Update the imports in `src/pages/New.tsx` to import `IonIcon` and the `heart` and `logoIonic` icons:
269270

270-
```tsx
271+
```tsx title="src/pages/New.tsx"
271272
import { IonBackButton, IonButtons, IonContent, IonHeader, IonIcon, IonPage, IonTitle, IonToolbar } from '@ionic/react';
272273
import { heart, logoIonic } from 'ionicons/icons';
273274
```
274275

275276
Then, include them inside of the `IonContent`:
276277

277-
```tsx
278+
```tsx title="src/pages/New.tsx"
278279
<IonIcon icon={heart} />
279280
<IonIcon icon={logoIonic} />
280281
```
@@ -287,9 +288,9 @@ For more information, see the [Icon documentation](/docs/api/icon) and the [Ioni
287288

288289
Let's add a button that can scroll the content area to the bottom.
289290

290-
Update `pages/New.tsx` to add a `ref` on `IonContent` and a button and some items after the existing icons:
291+
Update `src/pages/New.tsx` to add a `ref` on `IonContent` and a button and some items after the existing icons:
291292

292-
```tsx
293+
```tsx title="src/pages/New.tsx"
293294
<IonContent ref={content}>
294295
<IonIcon icon={heart} />
295296
<IonIcon icon={logoIonic} />
@@ -307,7 +308,7 @@ Update `pages/New.tsx` to add a `ref` on `IonContent` and a button and some item
307308

308309
Then, add the imports for the additional components and define the `scrollToBottom` function:
309310

310-
```tsx
311+
```tsx title="src/pages/New.tsx"
311312
import { useRef } from 'react';
312313
import { IonButton, IonBackButton, IonButtons, IonContent, IonHeader, IonIcon, IonItem, IonLabel, IonPage, IonTitle, IonToolbar } from '@ionic/react';
313314
import { heart, logoIonic } from 'ionicons/icons';

versioned_docs/version-v6/react/quickstart.md

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -53,30 +53,31 @@ After running `ionic serve`, your project will open in the browser.
5353

5454
## Explore the Project Structure
5555

56-
Your new app's `src` directory will look like this:
56+
Your new app's directory will look like this:
5757

5858
```shell
59-
├── App.tsx
60-
├── components
61-
│   ├── ExploreContainer.css
62-
│   └── ExploreContainer.tsx
63-
├── main.tsx
64-
└── pages
65-
   ├── Home.css
66-
   └── Home.tsx
59+
└── src/
60+
├── App.tsx
61+
├── components
62+
│ ├── ExploreContainer.css
63+
│ └── ExploreContainer.tsx
64+
├── main.tsx
65+
└── pages
66+
├── Home.css
67+
└── Home.tsx
6768
```
6869

6970
:::info
70-
All file paths in the examples below are relative to the `src/` directory.
71+
All file paths in the examples below are relative to the project root directory.
7172
:::
7273

7374
Let's walk through these files to understand the app's structure.
7475

7576
## View the App Component
7677

77-
The root of your app is defined in `App.tsx`:
78+
The root of your app is defined in `src/App.tsx`:
7879

79-
```tsx
80+
```tsx title="src/App.tsx"
8081
import { Redirect, Route } from 'react-router-dom';
8182
import { IonApp, IonRouterOutlet, setupIonicReact } from '@ionic/react';
8283
import { IonReactRouter } from '@ionic/react-router';
@@ -108,9 +109,9 @@ This sets up the root of your application, using Ionic's `IonApp` and `IonReactR
108109

109110
## View Routes
110111

111-
Routes are defined within the `IonRouterOutlet` in `App.tsx`:
112+
Routes are defined within the `IonRouterOutlet` in `src/App.tsx`:
112113

113-
```tsx
114+
```tsx title="src/App.tsx"
114115
<IonRouterOutlet>
115116
<Route exact path="/home">
116117
<Home />
@@ -125,9 +126,9 @@ When you visit the root URL (`/`), the `Home` component will be loaded.
125126

126127
## View the Home Page
127128

128-
The Home page component, defined in `pages/Home.tsx`, imports the Ionic components and defines the page template:
129+
The Home page component, defined in `src/pages/Home.tsx`, imports the Ionic components and defines the page template:
129130

130-
```tsx
131+
```tsx title="src/pages/Home.tsx"
131132
import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/react';
132133
import ExploreContainer from '../components/ExploreContainer';
133134
import './Home.css';
@@ -163,9 +164,9 @@ For detailed information about Ionic layout components, see the [Header](/docs/a
163164

164165
## Add an Ionic Component
165166

166-
You can enhance your Home page with more Ionic UI components. For example, import and add a [Button](/docs/api/button) at the end of the `IonContent` in `pages/Home.tsx`:
167+
You can enhance your Home page with more Ionic UI components. For example, import and add a [Button](/docs/api/button) at the end of the `IonContent` in `src/pages/Home.tsx`:
167168

168-
```tsx
169+
```tsx title="src/pages/Home.tsx"
169170
import { IonButton, IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/react';
170171
// ...existing imports...
171172

@@ -191,9 +192,9 @@ export default Home;
191192

192193
## Add a New Page
193194

194-
Create a new page at `pages/New.tsx`:
195+
Create a new page at `src/pages/New.tsx`:
195196

196-
```tsx
197+
```tsx title="src/pages/New.tsx"
197198
import { IonBackButton, IonButtons, IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/react';
198199

199200
const New: React.FC = () => {
@@ -223,21 +224,21 @@ export default New;
223224

224225
This creates a page with a [Back Button](/docs/api/back-button) in the [Toolbar](/docs/api/toolbar). The back button will automatically handle navigation back to the previous page, or to `/` if there is no history.
225226

226-
:::warning Important
227+
:::warning
227228
When creating your own pages, always use `IonPage` as the root component. This is essential for proper transitions between pages, base CSS styling that Ionic components depend on, and consistent layout behavior across your app.
228229
:::
229230

230231
## Navigate to the New Page
231232

232-
To navigate to the new page, create a route for it by first importing it at the top of `App.tsx` after the `Home` import:
233+
To navigate to the new page, create a route for it by first importing it at the top of `src/App.tsx` after the `Home` import:
233234

234-
```tsx
235+
```tsx title="src/App.tsx"
235236
import New from './pages/New';
236237
```
237238

238239
Then, add its route in `IonRouterOutlet`:
239240

240-
```tsx
241+
```tsx title="src/App.tsx"
241242
<IonRouterOutlet>
242243
<Route exact path="/home">
243244
<Home />
@@ -251,9 +252,9 @@ Then, add its route in `IonRouterOutlet`:
251252
</IonRouterOutlet>
252253
```
253254

254-
Once that is done, update the button in `pages/Home.tsx`:
255+
Once that is done, update the button in `src/pages/Home.tsx`:
255256

256-
```tsx
257+
```tsx title="src/pages/Home.tsx"
257258
<IonButton routerLink="/new">Navigate</IonButton>
258259
```
259260

@@ -265,16 +266,16 @@ Navigating can also be performed programmatically using React Router's `history`
265266

266267
Ionic React comes with [Ionicons](https://ionic.io/ionicons/) pre-installed. You can use any icon by setting the `icon` property of the `IonIcon` component.
267268

268-
Update the imports in `pages/New.tsx` to import `IonIcon` and the `heart` and `logoIonic` icons:
269+
Update the imports in `src/pages/New.tsx` to import `IonIcon` and the `heart` and `logoIonic` icons:
269270

270-
```tsx
271+
```tsx title="src/pages/New.tsx"
271272
import { IonBackButton, IonButtons, IonContent, IonHeader, IonIcon, IonPage, IonTitle, IonToolbar } from '@ionic/react';
272273
import { heart, logoIonic } from 'ionicons/icons';
273274
```
274275

275276
Then, include them inside of the `IonContent`:
276277

277-
```tsx
278+
```tsx title="src/pages/New.tsx"
278279
<IonIcon icon={heart} />
279280
<IonIcon icon={logoIonic} />
280281
```
@@ -287,9 +288,9 @@ For more information, see the [Icon documentation](/docs/api/icon) and the [Ioni
287288

288289
Let's add a button that can scroll the content area to the bottom.
289290

290-
Update `pages/New.tsx` to add a `ref` on `IonContent` and a button and some items after the existing icons:
291+
Update `src/pages/New.tsx` to add a `ref` on `IonContent` and a button and some items after the existing icons:
291292

292-
```tsx
293+
```tsx title="src/pages/New.tsx"
293294
<IonContent ref={content}>
294295
<IonIcon icon={heart} />
295296
<IonIcon icon={logoIonic} />
@@ -307,7 +308,7 @@ Update `pages/New.tsx` to add a `ref` on `IonContent` and a button and some item
307308

308309
Then, add the imports for the additional components and define the `scrollToBottom` function:
309310

310-
```tsx
311+
```tsx title="src/pages/New.tsx"
311312
import { useRef } from 'react';
312313
import { IonButton, IonBackButton, IonButtons, IonContent, IonHeader, IonIcon, IonItem, IonLabel, IonPage, IonTitle, IonToolbar } from '@ionic/react';
313314
import { heart, logoIonic } from 'ionicons/icons';

0 commit comments

Comments
 (0)