Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

113
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda