@oneschema/react
TypeScript icon, indicating that this package has built-in type declarations

0.5.3 • Public • Published

OneSchema Importer

A tool for embedding OneSchema into your application with React. This library contains a React component which will allow you to add an iframe to your application which can open OneSchema and import data into your application.

Getting Started

Installation

You can install this package with npm:

npm i --save @oneschema/react

Sample usage

import React, { useState } from "react"
import OneSchemaImporter from "@oneschema/react"

function OneSchemaExample() {
  const [isOpen, setIsOpen] = useState(false)

  const handleData = (data) => {
    console.log(data)
  }

  return (
    <div>
      <button onClick={() => setIsOpen(true)}>Import</button>

      <OneSchemaImporter
        /* managing state from your application */
        isOpen={isOpen}
        onRequestClose={() => setIsOpen(false)}
        /* required config values */
        clientId={clientId}
        userJwt={token}
        templateKey={templateKey}
        /* optional config values */
        importConfig={{ type: "local", metadataOnly: false, }}
        devMode={process.env.NODE_ENV !== "production"}
        className="oneschema-importer"
        style={{
          position: "fixed",
          top: 0,
          left: 0,
          width: "100vw",
          height: "100vh",
        }}
        inline={false}
        /* handling results */
        onSuccess={handleData}
        onCancel={() => console.log("cancelled")}
        onError={(error) => console.log(error)}
      />
    </div>
  )
}

Documentation

Please see 📚 OneSchema's documentation for 📒 API reference and other helpful guides.

Readme

Keywords

none

Package Sidebar

Install

npm i @oneschema/react

Weekly Downloads

15,492

Version

0.5.3

License

MIT

Unpacked Size

549 kB

Total Files

16

Last publish

Collaborators

  • rtdavis22
  • matthewoey
  • 20michaelz
  • andrewjluo
  • ryapapap