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

108
Views
¿Windows.getselection no se puede almacenar?

Es la primera vez que publico, así que espero que mi explicación sea clara.

Estoy desarrollando en React.js y quiero incluir emojis en mi editor, pero tengo que hacer clic en el ícono de emoji y seleccionar el emoji para integrarlo dentro de mi editor.

Entonces, necesito almacenar mi selección para colocar el emoji en el lugar adecuado. Aquí hay un ejemplo que funciona igual, la selección debe almacenarse solo al cambiar el área de texto, pero si selecciono el título y hago clic en el botón para registrar la selección, la última selección almacenada es el título.

 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> ); }

Si desea ejecutarlo, aquí está el codesandbox: https://codesandbox.io/s/heuristic-shape-u18vsh?file=/src/App.js:0-526

Gracias por la ayuda :)

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!