Skip to content
Advertisement

react save possibility to select text with re-render component

i have component with text. It changed component own state with mouse click. But i want to save possibility to select and copy in by long click. Is there way to make it ? Selection is reset after rerender component. Code for example:

JavaScript

Advertisement

Answer

How about using onMouseDown and onMouseUp events yourself and calculate the time the user took to click instead of using onClick? You could for example do something like this:

JavaScript

You can find a quick codesandbox as a demo here

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement