diff --git a/package.json b/package.json index 3fa3040..ae6de07 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "react-tag-input-component", "description": "lightweight component for tag(s) input", - "version": "1.1.2", + "version": "1.1.3", "license": "MIT", "author": "Harsh Zalavadiya", "repository": "https://github.com/hc-oss/react-tag-input-component", diff --git a/src/index.tsx b/src/index.tsx index 90debad..53ef140 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -88,6 +88,12 @@ export const TagsInput = ({ onChange && onChange(tags); }, [tags]); + useEffect(() => { + if (JSON.stringify(value) !== JSON.stringify(tags)) { + setTags(value) + } + }, [value]) + const handleOnKeyUp = e => { e.stopPropagation(); diff --git a/stories/tags-input.stories.tsx b/stories/tags-input.stories.tsx index 7deeaa9..4a72a60 100644 --- a/stories/tags-input.stories.tsx +++ b/stories/tags-input.stories.tsx @@ -32,7 +32,7 @@ export const Page = () => { isEditOnRemove={isEditOnRemove} beforeAddValidate={beforeAddValidate} /> -
Disable: {JSON.stringify(disabled)}
Keep Words on Backspace: {JSON.stringify(isEditOnRemove)}