Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

111
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda