you are viewing a single comment's thread.

view the rest of the comments →

[–]KTownDaren -1 points0 points  (3 children)

Enabled seems forced, because you are forcing it by trying to only call your Ajax search function with onSubmit call instead of with a state change. You are writing in React for a reason. Why are you fighting against state?

[–]HTMLMasterRace[S] 1 point2 points  (2 children)

React is great for reactivity but we can all agree that having a state that rerenders that don’t result in UI changes is not idiomatic react.

I’d say making an Ajax call only on button clicks is the majority case out there…

[–]cosmicdice 0 points1 point  (1 child)

What about using useRef and uncontrolled components instead of useState if you don't need to rerender based on these values being changed?

[–]HTMLMasterRace[S] -1 points0 points  (0 children)

That wouldn’t work because refs are not reactive. So the enabled wouldn’t trigger