How to create a new page on Ionic with react?
Asked Answered
C

2

5

I run command ionic generate pages/login but me return this error

Since you're using the React project type, this command won't work. The Ionic CLI doesn't know how to generate framework components for React

Confusion answered 9/1, 2020 at 1:59 Comment(0)
Z
10

You'll have to make a new file in e.g src/pages/ (e.g. with the name xy.tsx) with the following contents:

import React from "react";
import {IonPage} from "@ionic/react";
const PageXY: React.FC = () => {
    return (
        <IonPage>
            ...
        </IonPage>
    );
};

export default PageXY;

and in your App.tsx aka Router you have to import it with import PageXY from "./pages/xy"; and hook it up to the Router like so: <Route path="/xy" component={PageXY} exact />

Hope this still helps someone

Zwick answered 28/8, 2020 at 7:16 Comment(0)
R
-2

You can use this:

npx create-react-app login-app

Roderick answered 29/9, 2023 at 14:45 Comment(1)
So you create the application, I only need to create a new interfaceConfusion

© 2022 - 2024 — McMap. All rights reserved.