An open API service indexing awesome lists of open source software.

https://github.com/nativescript/capacitor-react-demo


https://github.com/nativescript/capacitor-react-demo

Last synced: 5 months ago
JSON representation

Awesome Lists containing this project

README

          

A simple React Ionic demo with @nativescript/capacitor example wired.

Try it out:
```
npm install
npm run build:mobile
npx cap sync
npx cap run ios
// or...
npx cap run android
```

## How this demo was created

```
npm install -g @ionic/cli
ionic start
> React
> sidedrawer

npm install @capacitor/cli@next @capacitor/core@next @capacitor/android@next @capacitor/ios@next

npx cap init

// this creates the build directory in order to add platforms
npm run build

npx cap add android
npx cap add ios

// Now ready for NativeScript
npm i @nativescript/capacitor --save

```

Now add add bindings/wirings in any component, ie: ExploreContainer.tsx:
```
import './ExploreContainer.css';
import { native } from '@nativescript/capacitor';

const ExploreContainer: React.FC = ({ name }) => {
function handleClick(e: React.MouseEvent) {
e.preventDefault();
native.openNativeModalView();
}
return (


{name}


Open Native Modal



);
};

export default ExploreContainer;
```

Now build for mobile (builds react and nativescript together) and prepare to run:
```
npm run build:mobile

// Now sync
npx cap sync

// Now just run the app:
npx cap run ios
// or...
npx cap run android
```