-
What I'm trying to do is modify (toggle) the background color of a div when it is clicked. So I have something like bgcol, set_bgcol = idom.hooks.use_state('red')
return idom.html.div(
{
'onClick': lambda e: set_bgcol('blue' if bgcol == 'red' else 'red'),
'style': {'background-color': bgcol}
},
"ipsum lorem",
bgcol
) inside a component. I have tried this and a few other variations and so far no luck. I put the text of bgcol into the div as well in order to verify that it is in fact changing. It is, but the style attribute of the div tag is not. What is/would be (if not implemented yet) the preferred way of doing this? |
Beta Was this translation helpful? Give feedback.
Answered by
rmorshea
Nov 11, 2021
Replies: 1 comment
-
All names in IDOM are |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rmorshea
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All names in IDOM are
camelCase
so the style attribute should bebackgroundColor