Registry / web-framework / reacton

reacton

JSON →
library1.9.1pypypi✓ verified 86d ago

Reacton is a pure Python library that ports the declarative UI paradigm of React (JavaScript) to the ipywidgets ecosystem. It enables developers to build reusable and composable user interface components within Jupyter notebooks and web applications built with ipywidgets, by offering a declarative approach to state and UI management. It aims to simplify complex UI logic, reduce boilerplate, and enhance maintainability, serving as a foundation for frameworks like Solara. The current version is 1.9.1, with updates released on a feature-ready basis rather than a strict cadence.

pip install reacton
INSTALL
IMPORT
SIG · REACTON
R
reacton
web-frameworkpythonv1.9.1
Install
5.2s avg
Import
1876ms
Disk
80MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.9.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 1.993s · 87.1MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 5.2s · import 1.758s · 88MB
80MB installed
● package 80MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

component
✓ from reacton import component
✗ import reacton @reacton.component
use_state
✓ from reacton import use_state
✗ import reacton reacton.use_state
render
✓ from reacton import render
✗ import reacton reacton.render

This example creates a simple button component that updates its click count using Reacton's `use_state` hook and a declarative approach to UI rendering within a Jupyter environment.

import reacton import reacton.ipywidgets as w from IPython.display import display @reacton.component def ButtonClick(): clicks, set_clicks = reacton.use_state(0) def my_click_handler(): set_clicks(clicks + 1) button = w.Button( description=f"Clicked {clicks} times", on_click=my_click_handler ) return button display(ButtonClick())
Debug
Known issues
gotchaWhen integrating with existing `ipywidgets` or custom widgets, Reacton assumes that widget constructor arguments match their underlying traits. Discrepancies can lead to runtime errors.
fix
Ensure that arguments passed to widget constructors, especially when creating custom wrappers, precisely align with the widget's traitlets. If issues arise, consider opening an issue on the Reacton GitHub.
affects: All versions
gotchaDirectly manipulating ipywidgets' elements via `ipywidgets.Widget.element(...)` bypasses Reacton's type-safe wrappers. This can lead to a less robust development experience, lacking type completion and static analysis.
fix
Prefer importing `reacton.ipywidgets as w` and using its wrapped components (e.g., `w.Button`) for better type safety, IDE support, and full integration with Reacton's lifecycle.
affects: All versions
gotchaAttempting to manage UI state or event handlers imperatively (outside of Reacton's `use_state`, `use_effect`, etc.) can lead to inconsistent UI behavior, memory leaks, and difficult-to-debug issues, similar to common pitfalls in non-declarative UI frameworks.
fix
Embrace Reacton's declarative paradigm by using `reacton.use_state` for local component state and other Reacton hooks for side effects and lifecycle management. Avoid directly modifying widget properties or adding/removing event handlers manually once a component is rendered.
affects: All versions
Upgrade
Version history
1.9.1latest on PyPI · released Feb 10, 2025
Audit
Dependencies
ipywidgetsrequiredCore dependency for UI rendering in Jupyter environments.
typing_extensionsrequiredProvides backported and experimental type hints.
Agent activity
6 hits · last 30 days
node
6
Resources
reacton — pip install reacton · libregistry