1import { useSelectedText } from 'react-modern-hooks'23const Demo = () => {4 const { error, selectedText, getSelectedText } = useSelectedText()56 if (error) {7 console.log('Error: ', error)8 }910 return (11 <div>12 <p>Highlight the text you need to ge selected</p>1314 <p>You highlighted the text: {selectedText}</p>1516 <div onMouseUp={() => getSelectedText()}>17 Only get selected from inside this div18 </div>19 </div>20 )21}2223export default Demo
No input variables
error - Error message during text selection
selectedText - The selected text
getSelectedText - An optional callback function (the hook has already taken care of this) which can be used to selected the text.