@oneschema/react
v0.7.0
Published
React component for using OneSchema
Downloads
133,079
Keywords
Readme
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.