Our Global Presence
Canada
57 Sherway St,
Stoney Creek, ON
L8J 0J3
India
606, Suvas Scala,
S P Ring Road, Nikol,
Ahmedabad 380049
USA
1131 Baycrest Drive,
Wesley Chapel,
FL 33544
In our previous blog post we learned basics about Ionic React app. Next, in this post let’s take a tour of what a stock Ionic React app consists of.
Open up the project in your favorite code editor and leave the ionic serve
command running. Any changes we make will automatically be recompiled and refresh the app in the browser.
An Ionic React project is just a React project, with the setup you would normally find from a CRA app. One difference you might notice is that we use TypeScript.
We are big fans of TypeScript at Ionic, and we believe TypeScript in React provides a great, productive experience. However, if you want to use plain JavaScript, rename the files to use a .js
extension and remove any of the type annotations from within the file, and your Ionic React app will now be a JavaScript app!
The src
folder contains all the code for the app. The main entry point is the App.tsx
file. Let’s break down what’s happening in this file.
At the top, we have the typical React and React Router imports, and then a series of imports from @ionic/react
. Each of our Ionic components is exported as its own individual React component. In essence, Ionic React is a wrapper around the web components we have in the Ionic Core project but exported in a way that makes them feel native to a React developer. Any updates and enhancements we make to Ionic Core will automatically be available in Ionic React.
Next, we import a series of core CSS files. After those, there is also a variables.css
file, which you can use to customize the theme of your app. For more info on theming your app, check out our doc
on the subject.
Next, we have the main App component. Notice that in the starters, we are using 100% functional components. We are fans of this approach, but if you prefer class-based components, those work great as well.
Each Ionic app starts with the IonApp component, which is the base container, and helps set up the screen to work great on both mobile and desktop. Next, the IonReactRouter component is a wrapper around the React Router library’s BrowserRouter component. To do the native-like page transitions and to maintain the state of the pages as you browse through your app, we augment React Router with some additional functionality.
The bulk of our tabs starter is now in the IonTabs
component. The IonRouterOutlet
contains a series of Routes (from React Router) for each of the pages in the tab interface.
Next, the IonTabBar
component contains the bottom tab bar with a button for each of the pages, which forward to the Tab1
, Tab2
, and Tab3
components in the src/pages
folder. The Tab1
and Tab2
pages have good examples on how to use some common Ionic components, but the Tab3
page is relatively bare. Let’s change that.
We will set up our empty tab to be a page to show a list of employees, with some demo data being pulled from the UIFaces
project.
First, let’s update the tab bar in App.tsx to show a new label and icon:
<IonTabButton tab="tab3" href="/tab3"> <IonIcon icon={people} /> <IonLabel>Employees</IonLabel> </IonTabButton>
The people icon is imported from 'ionicons/icons'
Open up Tab3.tsx
, and replace the contents of the file with:
<IonTabButton tab="tab3" href="/tab3"> <IonIcon icon={people} /> <IonLabel>Employees</IonLabel> </IonTabButton>
The people icon is imported from 'ionicons/icons'
Open up Tab3.tsx
, and replace the contents of the file with:
import { IonAvatar, IonContent, IonHeader, IonItem, IonLabel, IonList, IonPage, IonTitle, IonToolbar, useIonViewWillEnter } from '@ionic/react'; import React, { useState } from 'react'; interface Person { name: string; email: string; position: string; photo: string; } const Tab3Page: React.FC = () => { const [people, setPeople] = useState<Person[]>([]); useIonViewWillEnter(async () => { const result = await fetch('https://uifaces.co/api?limit=25', { headers: { 'x-API-KEY': '873771d7760b846d51d025ac5804ab' } }); const data = await result.json(); setPeople(data); }); return ( <IonPage> <IonHeader> <IonToolbar> <IonTitle>Employees</IonTitle> </IonToolbar> </IonHeader> <IonContent> <IonList> {people.map((person, idx) => <EmployeeItem key={idx} person={person} />)} </IonList> </IonContent> </IonPage> ); }; const EmployeeItem: React.FC<{ person: Person }> = ({ person }) => { return ( <IonItem > <IonAvatar slot="start"> <img src={person.photo} /> </IonAvatar> <IonLabel> <h2>{person.name}</h2> {person.position} </IonLabel> </IonItem> ); } export default Tab3Page;
First, we define a TypeScript interface for a Person, which will give us some type safety and code completion when using the employees a bit later on.
At the top, we import a couple of React hooks to use, the first is useState
, which allows us to use state in our functional components, and the second is useIonViewWillEnter
, which is a lifecycle method provided by Ionic that will fire each time the view comes into view.
We provide a function to the useIonViewWillEnter
hook that will fire that will call into the UIFaces API (using the fetch API) and return a list of twenty-five people. When the fetch request finishes, we call setPeople to update the people state variable.
In the JSX, we have an ‘IonList’ component, which contains an EmployeeItem
for each of the people. We separate out the EmployeeItem into its own component (defined a bit farther down).
With the updates to Tab3, we can now get a list of employees:
That is the basics on getting up and running with an Ionic React app!
For more Information and to build the app using Ionic, Hire Ionic Developer from us as we give you a high-quality product by utilizing all the latest tools and advanced technology. E-mail us any clock at – hello@hkinfosoft.com or Skype us: “hkinfosoft“.
To develop the Hybrid mobile app using Ionic, please visit our technology page.
Source:
Ionic React is a native React version of Ionic Framework that makes it easy to build apps for iOS, Android, Desktop, and the web as a Progressive Web App. All with one code base, standard React development patterns, and using the standard react-dom library and huge ecosystem around the web platform.
Ionic React represents the most significant change in Ionic Framework’s history and opens up Ionic Framework to a whole new audience.
For those that have been following Ionic since the early days, it might be a surprise to hear that we now support more than just Angular, and React of all things!
When we started Ionic Framework, the mission was to empower web developers to build top-quality apps using their existing web development skills, focused on the massive ecosystem around the web platform and web technology.
You might be wondering why we’d build Ionic React when React already has a great mobile option with React Native.
However, when we took a step back, we realized that Ionic React brought something pretty unique to the React ecosystem, and had a very different vision for what the future of app development might look like.
Instead of building an abstraction on top of iOS and Android native UI controls, we wanted to build something that was DOM-native, that would use the standard react-dom library and all the libraries that supported it out of the box, and the decades of existing work around the browser. When we looked at installs for react-dom compared to react-native, it was clear to us that vastly more React development was happening in the browser and on top of the DOM than on top of the native iOS or Android UI systems (16x more, in fact!). That further confirmed our belief that “web devs wanna web dev” and take advantage of their experience and existing library of functionality they’ve built on the DOM.
On top of that, developers are increasingly interested in Progressive Web Apps, especially in the enterprise. PWAs are, at best, an afterthought in the React Native ecosystem (and actually, not officially supported). In contrast, Ionic Framework is one of the leading PWA solutions and has some of the best performance for PWAs in the entire web ecosystem, thanks in part to our work on our Stencil project which we use to generate highly efficient components under the hood.
While Ionic still supports Cordova, new Ionic apps run on an all-new cross-platform engine called Capacitor that we built in-house. Capacitor takes modern JS and browser features, and makes it possible to deploy one app across iOS, Android, Electron, and the web as a Progressive Web App.
In fact, Progressive Web App support was a major goal of Capacitor, and many Capacitor APIs have powerful PWA support, such as Camera which has a custom UI experience available for adding native-quality camera features to your PWA.
While it is inspired by Cordova, in practice the development experience is very different. Capacitor is available as a modern JS API you can import directly into your app, with easy-to-use APIs for everything from File management to Geolocation to app-to-app sharing, to Push and Local Notifications. And exposing new Native SDKs to Capacitor is incredibly easy, requiring just a bit of wrapper code with first-class support for Swift on iOS (Java on Android).
Note: The first official version of Ionic React is v4.11.
Getting started with Ionic React is easy. First, if you haven’t already done so, install the latest Ionic CLI:
npm i -g ionic
Already have a React app? Adding Ionic React is easy.
Then, create a new project:
ionic start my-react-app
The CLI will guide you through the setup process by first asking a couple of questions. The first of which is what framework you would like to use, select React
Next, the CLI will ask which starter template you would like to use.
The CLI will now create your app and install all the dependencies. Once it is done, go into the directory and launch the app:
ionic serve
Under the covers, the ionic serve command uses the Create React App
(CRA) project to compile your app, start a dev server, and open your app in a new browser window.
Once done, you will see your starter app up and running:
In our next blog, We will take a tour of what a stock Ionic React app consists of.
For more Information and to build the app using Ionic, Hire Ionic Developer from us as we give you a high-quality product by utilizing all the latest tools and advanced technology. E-mail us any clock at – hello@hkinfosoft.com or Skype us: “hkinfosoft“.
To develop the Hybrid mobile app using Ionic, please visit our technology page.
Source:
57 Sherway St,
Stoney Creek, ON
L8J 0J3
606, Suvas Scala,
S P Ring Road, Nikol,
Ahmedabad 380049
1131 Baycrest Drive,
Wesley Chapel,
FL 33544
57 Sherway St,
Stoney Creek, ON
L8J 0J3
606, Suvas Scala,
S P Ring Road, Nikol,
Ahmedabad 380049
1131 Baycrest Drive,
Wesley Chapel,
FL 33544
© 2025 — HK Infosoft. All Rights Reserved.
© 2025 — HK Infosoft. All Rights Reserved.
T&C | Privacy Policy | Sitemap