How to Get Started with React & Ionic?
Getting started is quite simple. Begin first with create-react-app, because we want you to use Ionic with React in the most familiar way. We also recommend using TypeScript in your app, something we recently wrote about on our blog if you need tips. While this is not required, we mention it because Ionic React ships with TypeScript type definitions, and it makes for an excellent developer experience. npx create-react-app my-ionic-app --typescript
cd my-ionic-app
Ionic provides components to help with navigation like tabs and
stack-based navigation. Right now, we support react-router so we will
need to install it as a dependency along with @ionic/react
.npm install @ionic/react react-router react-router-dom @types/react-router @types/react-router-dom
Fire up your favorite code editor and open up App.tsx. Then replace the contents of the file with:import React, { Component } from 'react';
import '@ionic/core/css/core.css';
import '@ionic/core/css/ionic.bundle.css';
import {
IonApp,
IonContent,
IonCard,
IonCardHeader,
IonCardTitle,
IonCardSubtitle
} from '@ionic/react';
class App extends Component {
render() {
return (
<IonApp>
<IonContent>
<IonCard>
<IonCardHeader>
<IonCardSubtitle>Welcome to Ionic</IonCardSubtitle>
<IonCardTitle>Running on React</IonCardTitle>
</IonCardHeader>
</IonCard>
</IonContent>
</IonApp>
);
}
}
export default App;
Run npm run start
and you got yourself an Ionic React app!Alright, that is pretty much it. From here, you can use Ionic Components as you wish. Now, let’s dive into the specifics of what components are available from Ionic.
0 comments:
Post a Comment