Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React hook form #22

Closed
Codemaine opened this issue Apr 11, 2024 · 3 comments
Closed

React hook form #22

Codemaine opened this issue Apr 11, 2024 · 3 comments

Comments

@Codemaine
Copy link

Please add the ability to use the register object directly with the input, so that we can validate them with React Hook form

@Codemaine
Copy link
Author

Codemaine commented Apr 11, 2024

I've found a temporary solution:
<Controller name="tags" control={control} rules={{ required: true }} render={({ field }) => <TagInput placeholder="Enter a topic" tags={tags} id="tags" maxTags={5} minTags={2} value={field.value} setTags={(newTags) => { setTags(newTags); field.onChange(newTags) }} title="Select up to 5 tags" />} />

@JaleelB
Copy link
Owner

JaleelB commented Apr 21, 2024

Hey @Codemaine. I'll take a look at this today

@JaleelB
Copy link
Owner

JaleelB commented May 2, 2024

@Codemaine Thank you for your suggestion and for engaging with the development of the component. After carefully considering the proposal to integrate React Hook Form's control and rules directly into TagInput, I have decided to not integrate the change. There isn't a compelling reason to tightly couple the TagInput with React Hook Form by handling control and rules directly, it's generally better to use Controller. This approach keeps the component flexible and clean, focusing on its primary functionalities while relying on React Hook Form to handle form state and validation externally

@JaleelB JaleelB closed this as completed May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants