Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

228
Views
¿Cómo usar .on en reaccionar?

Tengo un componente que usa la biblioteca tagify. Recibo un error que indica que tagify.on no es una función.

¿Cómo hago el .on en React? ¿Cómo agrego estos métodos .on a este componente tagify que estoy creando?

¿Los hago todos constantes y funciones de flecha?

 const tagify = new Tagify(tagsInput, { // mixTagsInterpolator: ["{{", "}}"], mode: 'mix', pattern: /@|#/, here) tagTextProp: 'text', whitelist: fields.map(function(item) { return typeof item == 'string' ? { value: item } : item }), dropdown: { enabled: 1, position: 'text', mapValueTo: 'text', highlightFirst: true }, callbacks: { add: console.log, // callback when adding a tag remove: console.log // callback when removing a tag } }); let tagsInput = createRef(); tagify.on('input', function(e) { < -- - this is giving error tagify.on is not a function const prefix = e.detail.prefix; if (prefix) { if (e.detail.value.length > 1) tagify.dropdown.show(e.detail.value); } console.log(tagify.value) console.log('mix-mode "input" event value: ', e.detail) }); tagify.on('add', function(e) { < -- - this is giving error tagify.on is not a function console.log(e) });
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Tenía algo similar al tuyo. Sugerencia:

  • Escribe todo el código superior en una función (excepto la let tagsInput = createRef(); ). Llámalo configureTagify o lo que sea.
  • Llámelo en un lugar apropiado (al principio, por ejemplo, el equivalente del componenteDidMount)

.

 useEffect(() => { ... configureTagify(); ... }, []);
about 4 years ago · Juan Pablo Isaza Report

0

Cuidando los documentos,

El método .on se proporciona para jQuery, no lo necesita. Puede usarlo en devoluciones de llamada:

 callbacks: { "input": (e) => console.log(e.detail))
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!