Is there a way to have javascript/css access the properties of dash elements on the client side?
My use case is that I would like to style some elements based on the number of times they were clicked using client side code (i.e. avoiding firing a callback)
I could tie my own click event and keep a counter, but since these are Dash elements and Dash is already doing that (dash-html-components , and that I’m actually relying on n_clicks inside some other callbacks, I figured it would be better to use the n_clicks property from dash/react.
I found a way to get the data as follow:
d = document.getElementById('myElementId')
d.__reactInternalInstance$uxbml8qv1w._currentElement.props.n_clicks
However that seems a bit hackish to have to access the internal state in that fashion, not to mention needing to figure out the $xxxx id everytime.
I ended up writing a function which returns the attribute that I care about. For example, in the code below I wanted to get access to the setProps function to trigger a callback manually.
Note: I did it with a dummy output in the example to show that you can do it but in this case you could update the style attribute of the button in the clientside callback.