Created
May 16, 2023 12:23
ipyreact-demo
This file contains 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