Closed
Description
Current Situation
Currently, there exists circumstances where set_state
can be called and nothing will occur. For example, modifying a mutable class (such as a dataclass
)
@dataclass
class MyState:
value: str = ""
@idom.component
def my_component():
state, set_state = idom.hooks.use_state(MyState())
async def on_click(event):
state.value = "dog"
set_state(state)
# This does not trigger a re-render. Need to use copy.copy(state).
return button( {"onClick"=on_click}, ... )
Proposed Changes
Notify the user if set_state
was called and no re-render was queued.
Implementation Details
When in IDOM_DEBUG_MODE
...
Show either logging.warning
or logging.info
when set_state
is called but a re-render was not trigged.