728x90

해당 페이지는 Ionic React 기준 에서 jeep-sqlite를 사용하는 것을 예시로 들어 작성

 

1)

main.tsx 

 

* 설치 라이브러리 

npm install @capacitor/core@latest @capacitor/cli@latest @capacitor/android@latest @capacitor/ios@latest
npm install @capacitor-community/sqlite@latest

 

* 해당 버전은 다음 버전으로 작성 및 테스트 되었음.

+-- @capacitor-community/sqlite@5.7.3-3
| `-- jeep-sqlite@2.7.1 deduped
`-- jeep-sqlite@2.7.1

 

main.tsx 예시 )

 
import React from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';

import { Capacitor } from "@capacitor/core";
import {
  CapacitorSQLite,
  SQLiteConnection,
} from "@capacitor-community/sqlite";
 
import {
  CapacitorSQLite,
  SQLiteConnection,
} from "@capacitor-community/sqlite";
import { JeepSqlite } from "jeep-sqlite/dist/components/jeep-sqlite";
 
 
window.addEventListener("DOMContentLoaded", async () => {
  try {
 
    const platform = Capacitor.getPlatform();
 
    if (platform === "web") {
      const sqlite = new SQLiteConnection(CapacitorSQLite);
      // Create the 'jeep-sqlite' Stencil component
      customElements.define("jeep-sqlite", JeepSqlite);
      const jeepSqliteEl = document.createElement("jeep-sqlite");
      document.body.appendChild(jeepSqliteEl);
      await customElements.whenDefined("jeep-sqlite");
      console.log(`after customElements.whenDefined`);
 
      await sqlite.initWebStore();
      console.log(`after initWebStore`);
    }

    const container = document.getElementById("root");
    const root = createRoot(container!);
    root.render(
      <React.StrictMode>
        <App />
      </React.StrictMode>
    );
  } catch (e) {
    console.log(e);
  }
});
 
  

 

 

728x90

+ Recent posts