Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add events #18

Closed
2 tasks done
jcubic opened this issue Oct 3, 2021 · 3 comments
Closed
2 tasks done

Add events #18

jcubic opened this issue Oct 3, 2021 · 3 comments
Labels
good first issue Good for newcomers

Comments

@jcubic
Copy link
Owner

jcubic commented Oct 3, 2021

Events are required for proper use in React to have proper binding.

  • Add change event
  • update React example to display all tags while they are changing
@lucasnetau
Copy link
Contributor

@jcubic I don't use ReactJS, however if native vanilla javascript change event is implemented, is there anything more for ReactJS support? State could be updated via the onChange react handler.

import { useRef, useState, useEffect } from 'react'
import tagger from '@jcubic/tagger'

function App() {
  const [tags, setTags] = useState(null)
  const inputRef = useRef(null)

  // Write the Tagger code inside a useEffect hook
  // It will run when the component is initially rendered
  useEffect(() => {
    // Define the Tagger options
    const taggerOptions = {
      allow_spaces: true,
    }

    // Initialize Tagger
    tagger(inputRef.current, taggerOptions)
  }, [])

  return (
    <div className='app'>
      <input type='text' defaultValue='charles, louis, michel' ref={inputRef} onChange={e => setTags(e.target.value)} />

      {tags && <pre>{tags}</pre>}
    </div>
  )
}

export default App

@jcubic
Copy link
Owner Author

jcubic commented Jul 27, 2023

Yea, you're right. I closed the PR too soon. I just wanted to have more events, but maybe they are not needed. I will checkout the PR locally add semicolons and merge.

@jcubic
Copy link
Owner Author

jcubic commented Jul 28, 2023

The PR got merged. I've changed the origin issue to only include the change event.

jcubic added a commit that referenced this issue Aug 1, 2023
@jcubic jcubic closed this as completed Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants