Reacton

Adding a pre_render hook to reacton codebase we’re able to track each state change at component level.

_original_render = _RenderContext.render

def pre_render(self, element: Element, container: widgets.Widget = None):
    print(f'state::{self.state_get()}\n')
    print(f'element: {element.component} --- {element.component.name}, {element.component.value_name}, {element.component.widget}\n')
    if container is not None:
        print(f'model_id::{container.model_id}')

def _patched_render(self, element: Element, container: widgets.Widget = None):
    pre_render(self, element, container)
    
    _original_render(self, element, container)

_RenderContext.render = _patched_render  # type: ignore

Testing

The following cells displays ipywidgets an solara example of monitoring state changes. Interact with the following widgets to intercept its state changes.

int_value = solara.reactive(0)
slider = solara.SliderInt("Another Test Slider:", value=int_value, min=0, max=10)