Tagify: Is it possible to use tagify methods with React?

Created on 10 Jun 2020  路  5Comments  路  Source: yairEO/tagify

I want to use use injectAtCaret method, but i'm stuck

Question

All 5 comments

You could clone the wrapper and make adjustments to your liking.

Please explain to me the situation in details

I want to implement field in mix mode, where i can insert tags on button click using react(preferably react hooks), and i can't explain how to use tagify methods such as injectAtCaret with tagify react wrapper

I will investigate this and will let you know here

Sorry it took a while to get back to you.

I've improved the demo page to show exactly how to access Tagify's internal methods:

You can now pass a ref which will act as the Tagify instance:

<Tags tagifyRef={tagifyRef} ...>
````

Then you can do whatever you want with this ref. In the above demo example, a "clear all" button does exactly that, so the `onClick` prop maps to this method:

```javascript
const clearAll = () => {
    tagifyRef.current && tagifyRef.current.removeAllTags()
}

@yairEO thank you!

Was this page helpful?
0 / 5 - 0 ratings