dpm
TTCTheo's Typesafe Cult
•Created by dpm on 2/18/2024 in #questions
What's the idiomatic way to enable/disable a button based on Zod results?
Hi,
New to React, not really a frontend developer.
I want to disable my button if my Zod schema doesn't like the field value. Ideally without adding a redundant
useState
to track whether the field is valid.
In the example below, I can use disabled = (nextItem === '')
, but that pattern won't scale to more complex validations (I assume).
I'm used to rxjs from Angular-land, I assume there's a reactive approach here as well. Or am I totally off-base?
1 replies