Render not triggered.
See original GitHub issueHi, I have a button component which is on a page. I want to use a prop to enable the button when proper validation has been completed. I can see that true is passed to the IsEnabled Prop but the Render method doesn’t get called again to enable the button. My code looks like this. I have read in other posts that you can just set the field directly instead of calling SetState(). Any suggestions? Thanks in advance.
private bool _isEnabled;
internal class SignUpButton : Component
{
public SignUpButton IsEnabled(bool isEnabled)
{
_isEnabled = isEnabled;
return this;
}
public override VisualNode Render() <====Doesn't get triggered when _isEnabled is set.
{
return new Button()
.Text("Sign up")
.Class("NextButton")
.WidthRequest(300)
.HCenter()
.IsEnabled(_isEnabled)
.OnClicked(OnSignUpButtonClicked);
}
}
Issue Analytics
- State:
- Created 2 months ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
react setState() not triggering re-render
React components automatically re-render whenever there is a change in their state or props. In your example, sortedPlans.sort is sorting the ...
Read more >React doesn't always trigger a re-render on setState
For new React developers, it is common to think that setState will trigger a re-render. But this is not always the case. If...
Read more >Why react does not re-render component when state is ...
I think it is because React only partially renders depending on what changes. The quickest way to fix this would be to call...
Read more >How and when to force a React component to re-render
The component did not change, so there was no re-rendering trigger. Here's why. React evaluates state changes by checking its shallow equality ( ......
Read more >React re-renders guide: everything, all at once
There are four reasons why a component would re-render itself: state changes, parent (or children) re-renders, context changes, and hooks ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ok, I see the problem: you’re adding more than one time the same behavior to the entry and also you aren’t checking the entry reference to be null. This is the fixed code:
BUT SEE BELOW
Using behaviors is not recommended in MauiReactor because they are just another MVVM “thing” to overcome a problem in the MVVM approach that it’s instead solved pretty easily in MVU.
For example, this is how I would rewrite your code in a pure MVU approach:
Thanks Ado, that did the trick!!!. I prefer the MVU approach over MVVM with XAML any day. I will go with the full MVU approach you suggested. Thanks again and great work on this project!!!.