Replies: 1 comment
-
I am sorry that you find it confusing. To answer your question, let me give you a quick overview how Conform understand a "field" first. As you might know, Conform utilizes
This is exactly what browsers does with all native inputs. However, this is usually missed on custom inputs. Depends on the implementation and the use of native input, it's very unlikely that it will dispatch the events like native input does and the reason why we can't setup a change / blur event listener on the form element and trigger a form submit whenever the user interactive with a custom input. My goal with Now, let's get back to your questions.
It depends on the setup. When you use function Exmaple() {
const inputRef = useRef(null);
const control = useInputEvent({
ref: inputRef,
});
return (
<>
<input name="something" ref={inputRef} defaultValue="" hidden>
<CustomInput onChange={control.change} />
</>
);
} However, this could be risky if the hidden input is managed by the CustomInput and mess up its internal state.
If you mean hidden input by Thanks for all the questions. They are totally valid and I can see why the current API is confusing. It is expecting the developer to have some basic ideas on how the input is implemented or rendered and then figure out how to improve it. I will try to come up with a different approach to simplify this process before v1. But I think the integration would also get simpler eventually as the react community continues to explore event delegation and hopefully takes native events as part of their contract. Also, we will be able to build more complex input with native element like selectmenu as the platform gets better and there is no need to do any integration one day. |
Beta Was this translation helpful? Give feedback.
-
I was quite confused the real usage of useInputEvent hook, and I have some unanswered questions:
useInputEvent
if I could just useuseState()
to update the hidden input?control.change
,control.focus
andcontrol.blur
. Because I noticed in the official examples, not all control methods are used in all integrated components.onFocus
handler inuseInputEvent
and theonFocus
property in the referenced input? (Vice versa foronChange
andonBlur
)Beta Was this translation helpful? Give feedback.
All reactions