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

Bug: types for value is optional but actually required #43

Open
namhong2001 opened this issue Dec 28, 2022 · 0 comments
Open

Bug: types for value is optional but actually required #43

namhong2001 opened this issue Dec 28, 2022 · 0 comments

Comments

@namhong2001
Copy link

const [tags, setTags] = useState<any>(value || []);

Here the code seems considered undefined value but below code makes the tags undefined and make throw error.
useDidUpdateEffect(() => {
if (JSON.stringify(value) !== JSON.stringify(tags)) {
setTags(value);
}
}, [value]);

IMO current code is not support uncontrolled component, so it would be good to have value and onChange props required

Someday for uncontrolled component may be form of

<form onSubmit={(e) => {
  e.preventDefault();
  const formData = new FormData(e.currentTarget);
  const tags = formData.get("tags"); // should be such like ["banana", "apple"]
}}>
  <TagsInput name="tags" />
</form>
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

1 participant