abinavseelan / react-input-trigger

React component for handling character triggers inside textareas and input fields. 🐼
MIT License
88 stars 20 forks source link

Cant set endTrigger with React Hook useState #19

Open conwayconstar opened 5 years ago

conwayconstar commented 5 years ago

I am using a functional component and I am unable to set the endTrigger with a set state function

<InputTrigger
        trigger={{
          keyCode: 50,
          shiftKey: true,
        }}
        onType={toggleSuggesting}
        onCancel={toggleSuggesting}
        endTrigger={setEndMention}
      >
ghost commented 4 years ago

Did you manage this @fullstackedkush ?

conwayconstar commented 4 years ago

I did not unfortunately, I used useRef to set a reference and created my own trigger to reset it with ref.current.resetState();

ghost commented 4 years ago

@fullstackedkush Had to assign to a variable to make it work, not the best solution, but it works. I'll change to your solutions, seems much cleaner to me.