Intento almacenarlo en el almacenamiento local pero no me funcionó. Me da un error cuando hago clic en el botón Guardar borrador.
import React, { useEffect, useState } from "react"; import "./App.css"; function App() { const [text, setText] = useState(""); const [totalcharacters, setTotalCharacters] = useState(0); const [totalword, setTotalWord] = useState(0); const handleDraft = (text) => { if (localStorage.setItem("text", JSON.stringify(text))) { setText(localStorage.getItem("text")); } }; useEffect(() => { setTotalCharacters(text.length); localStorage.setItem("text", text); function findTotal(text) { text = text.replace(/(^\s*)|(\s*$)/gi, ""); text = text.replace(/[ ]{2,}/gi, " "); text = text.replace(/\n /, "\n"); setTotalWord(text.split(" ").length); } findTotal(text); handleDraft(text); // setTotalWord(text.split(' ').length) }, [text, totalword]);