Created
May 16, 2023 12:23
-
-
Save kolibril13/4a3e7f26842a77eeb0f347f4b2870946 to your computer and use it in GitHub Desktop.
ipyreact-demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"import ipyreact\n", | |
"from traitlets import Unicode\n", | |
"\n", | |
"class QRCodeWidget(ipyreact.ReactWidget):\n", | |
" content = Unicode(\"\").tag(sync=True)\n", | |
" _esm = \"\"\"\n", | |
" import React from \"react\";\n", | |
" import QRCode from \"react-qr-code\";\n", | |
"\n", | |
" export default function App({ content }) {\n", | |
" return <QRCode value={content} />\n", | |
" }\n", | |
"\n", | |
" \"\"\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"QRCodeWidget(content=\"Hello World\")" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3 (ipykernel)", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.9.15" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment