i-like-robots/react-tags

How can I get clearInput() from API?

vladyslavM9 opened this issue · 1 comments

image

I need to clear my input, I'm added ref to my ReactTags component, but I can not see any API methods in this ref

image

Taking the example shown in the readme:

function CountrySelector () {
  const [tags, setTags] = useState([])

  const reactTags = useRef()

  const onDelete = useCallback((tagIndex) => {
    setTags(tags.filter((_, i) => i !== tagIndex))
  }, [tags])

  const onAddition = useCallback((newTag) => {
    setTags([...tags, newTag])
  }, [tags])

  return (
    <>
      <p>Select the countries you have visited below:</p>
      <ReactTags
        ref={reactTags}
        tags={tags}
        suggestions={suggestions}
        noSuggestionsText='No matching countries'
        onDelete={onDelete}
        onAddition={onAddition}
      />
      <p><b>Output:</b></p>
      <pre><code>{JSON.stringify(tags, null, 2)}</code></pre>
+     <button onClick={() => reactTags.current.clearInput()}>Clear</button>
    </>
  )
}