Skip to content

Style Cannot Be Updated #480

Closed
Closed
@rmorshea

Description

@rmorshea

When clicking the button in the code below it's background color should change, but it does not:

import idom


@idom.component
def Test():
    color_toggle, set_color_toggle = idom.hooks.use_state(False)
    color = "red" if color_toggle else "blue"
    return idom.html.div(
        idom.html.button(
            {
                "onClick": lambda event: set_color_toggle(not color_toggle),
                "style": {"backgroundColor": color, "color": "white"},
            },
            "toggle",
        ),
    )


idom.run(Test, port=5000)

Originally reported by @jgburford in #478 (reply in thread)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions