No page re-render despite change in reactive value

Open
#282 0 comments 0 reactions 1 assignee View on GitHub

@iisakkirotko is already working on this.

Since Sep 7, 2023.

Assessment

This issue has not been assessed yet.

Description

bug

On initial load, the page is not re-rendered even though the value of a reactive variable changes. In the example below, when the page is initially loaded, the value of var, as displayed in the Text component is None, even though in both the InputText and via clicking on the button, we find that the value has actually changed to become '!!!', see screenshot.

import solara

var = solara.Reactive(None)

def on_click():
    print(var)

@solara.component
def BugComponent(
    value: solara.Reactive[str],
    on_value = None,
):
        
    def on_change(event_value):
        value.set(event_value)

    if value.value is None:
        value.set('!!!')

    return solara.InputText(label='', value=value, on_value=on_change)

@solara.component
def Page():
    BugComponent(value = var)

    solara.Text(f"{var}")
    solara.Button('click', on_click=on_click)
image
Dominant language
Python
Stars
2.2k
Forks
202
Avg merge
4h 36m
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from widgetti/solara

All issues in widgetti/solara

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.