Skip to content

Can't figure out simple state updates in Dioxus #1438

Answered by tigerros
pcgeek86 asked this question in Q&A
Discussion options

You must be logged in to vote

As you can see, I used the oninput event instead of onkeyup, since oninput is an event that gives you the new value of the input. You might also be interested in the User Input chapter of the docs. It describes an alternative to handling input within each input element, instead delegating all work to the form.onsubmit event. Of course, you would also need to create a form element. However, then the input validation (which I've added for your convenience), would only work once the form is submitted, and not instantly when the input is entered.

IF you wish to simplify this process, consider making your own, "upgraded", input component.

fn Calculator(cx: Scope) -> Element {
    let calc_stat…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by pcgeek86
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants