Skip to content
Liminoid
GitHub

Using the React component

$ yarn add liminoid-react

or

$ npm install --save liminoid-react

Usage

Webpage embedding examples.

// easiest to use ES6 imports from the UNPKG CDN
import Liminoid from 'https://unpkg.com/liminoid-react';
const placeholder = `
from sklearn import svm
from sklearn import datasets
clf = svm.SVC()
X, y = datasets.load_iris(return_X_y=True)
clf.fit(X, y)
clf.predict(X[0:1])
`;
<Liminoid
packages={['scikit-learn']}
console={true}
edit={true}
scope={false}
onResult={res => console.log(res)}
code={placeholder}
/>

props

namedefaultvaluesdescription
packages[]Array: package names currently avalable in PyodideUses Pyodide's loadPackage() to preload packages
consoletrueBoolean: true or falsefalse disables the HTML console which displays the results.
edittrueBoolean: true or falsefalse disables the textarea input while still allowing the embedded code to be run.
scopefalseBoolean: true or falsetrue creates a new Repl() for the component with its own Python context. false shares the Repl() context between editors globally, i.e. one editor can reference variables from another.
onResultundefinedFunction: function expression or referencecallback function that receives the results when the code is run. (res, err) => { ... }
codeundefinedString or template literalplaceholder code that populates the editor component on initialization.
Edit this page on GitHub
GithubChatTwitterStack OverflowContributingColophonCitation