A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/reactive-python/reactpy-jupyter below:

reactive-python/reactpy-jupyter: It's React, but in Jupyter

A client for ReactPy implemented using Jupyter widgets

Check out some live examples by clicking the badge below:

To install use pip:

pip install reactpy_jupyter

Once you're done getting started, you can author and display ReactPy layouts natively in your Jupyter Notebook:

import reactpy

@reactpy.component
def ClickCount():
    count, set_count = reactpy.hooks.use_state(0)
    return reactpy.html.button(
        {"onClick": lambda event: set_count(count + 1)},
        [f"Click count: {count}"],
    )

ClickCount()

You can also turn an reactpy element constructor into one that returns an ipywidget with the reactpy_juptyer.to_widget function. This is useful if you wish to use ReactPy in combination with other Jupyter Widgets as in the following example:

ClickCountWidget = reactpy_jupyter.to_widget(ClickCount)
ipywidgets.Box(
    [
        ClickCountWidget(),
        ClickCountWidget(),
    ]
)

For a more detailed introduction check out this live demo here:

For a development installation (requires Node.js and Yarn version 1),

$ git clone https://github.com/reactive-python/reactpy-jupyter.git
$ cd reactpy-jupyter
$ pip install -e .

To automatically re-build and refresh Jupyter when making changes start a Vite dev server:

Then, before importing reactpy_jupyter set the following environment variable:

import os
os.environ["REACTPY_JUPYTER_DEV"] = "1"
import reactpy_jupyter

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4