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

114
Views
Windows.getselection cannot be stored?

First time posting, so I hope my explanation will be clear.

I'm developing on React.js and I want to to include emojis to my editor but I have to click on emoji icon and select the emoji to integrate him inside my editor.

So, I need to store my selection to place the emoji at the good place. Here is an exemple that works the same, the selection should be stored only when changing the text area but if I select the title and I click on the button to log the selection, the last selection stored is the title

export default function App() {
  const [sel, setSel] = useState();
  const handleChange = () => {
    setSel(window.getSelection);
  };
  console.log(sel);

  return (
    <div className="App">
      <button
        onClick={() => {
          console.log(sel);
        }}
      >
        button
      </button>
      <h1>Title</h1>
      <p>Text</p>
      <textarea
        onChange={() => {
          handleChange();
        }}
      ></textarea>
    </div>
  );
}

If you want to run to run it, here is the codesandbox : https://codesandbox.io/s/heuristic-shape-u18vsh?file=/src/App.js:0-526

Thanks for the help :)

about 4 years ago · Santiago Gelvez
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!