adospace / reactorui-maui

MauiReactor is a MVU UI framework built on top of .NET MAUI
MIT License
552 stars 45 forks source link

How to force component re-rendering? #211

Closed zxyao145 closed 4 months ago

zxyao145 commented 4 months ago

Hi, same as title, how to force component re rendering?

adospace commented 4 months ago

When you call SetState() you set the state and automatically invalidate the component (that in turn schedules a component re-rendering).

If you want to set the state without re-rendering call SetState(.., invalidateComponent: false) (this is required when you don't want to re-render the component and usually happens when you have property linked to the state using a function like ()=>State.Counter).

If you want to re-render the component just call the Invalidate() (this is required in some special cases).

This page can help: https://adospace.gitbook.io/mauireactor/components/stateful-components

zxyao145 commented 4 months ago

@adospace Hi, Thank you for your reply! Through step-by-step debugging, I found that it was because the code threw an exception, which resulted in the subsequent SetState not being re-rendered. I am a beginner on Android, and I'm not sure if this meets expectations.