How can I get clearInput() from API?
vladyslavM9 opened this issue · 1 comments
vladyslavM9 commented
i-like-robots commented
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>
</>
)
}