Skip to content

Properly cleanup when the Widget is initialized by an implicit as_widget() #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to shinywidgets will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [UNRELEASED]

* Fixed an issue introduced by v0.6.0 where cleanup not happening when it should. (#195)

## [0.6.0] - 2025-05-19

* Widgets initialized inside a `reactive.effect()` are no longer automatically removed when the effect invalidates. (#191)
Expand Down
5 changes: 4 additions & 1 deletion shinywidgets/_render_widget_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ def __init__(

async def render(self) -> Jsonifiable | None:
with WidgetRenderContext(self.output_id):
value = await self.fn()
return await self._render()

async def _render(self) -> Jsonifiable | None:
value = await self.fn()

# Attach value/widget attributes to user func so they can be accessed (in other reactive contexts)
self._value = value
Expand Down