A JupyterLab and Jupyter Notebook extension for rendering data with dynamically loaded React components
- JupyterLab ^0.16.0 and/or Notebook >=4.3.0
To render React output in IPython:
from jupyterlab_react import React
element = {
'type': 'JSONTree',
'props': {
'data': [
{'month': 'September', 'profit': 35000, 'loss': 2000},
{'month': 'October', 'profit': 42000, 'loss': 8000},
{'month': 'November', 'profit': 55000, 'loss': 5000}
],
'theme': 'google'
}
}
React(element, module='react-json-tree')
To install using pip:
pip install jupyterlab_react
# For JupyterLab
jupyter labextension install --py --sys-prefix jupyterlab_react
jupyter labextension enable --py --sys-prefix jupyterlab_react
# For Notebook
jupyter nbextension install --py --sys-prefix jupyterlab_react
jupyter nbextension enable --py --sys-prefix jupyterlab_react
Use the install.sh
script to build the Javascript, install the Python package, and install/enable the notebook and lab extensions:
bash install.sh --sys-prefix
Use the build.sh
script to rebuild the Javascript:
bash build.sh
Alternatively, see the README.md
in /labextension
and /nbextension
for extension-specific build instructions.
To install the Python package:
pip install -e .
To install the extension for JupyterLab:
jupyter labextension install --symlink --py --sys-prefix jupyterlab_react
jupyter labextension enable --py --sys-prefix jupyterlab_react
To install the extension for Jupyter Notebook:
jupyter nbextension install --symlink --py --sys-prefix jupyterlab_react
jupyter nbextension enable --py --sys-prefix jupyterlab_react