const DataList = () => { al principio y al final, pero no funcionó
Agregue la exportación predeterminada a este código porque muestra un error en el componente de mi aplicación
import { render } from '@testing-library/react' import React,{useState} from 'react' import ReactDOM from 'react-dom/client'; const Thingy = ({...props}) => { const [userInput, setUserInput] = useState(''); const [showResult, setShowResult] = useState(false); const handleChange = ev => (setUserInput(ev.target.value), setShowResult(false)); const convertChar = ch => { const c = ch.toLowerCase(); if ('0' <= c && c <= '9') return ch.toString(); if (!('a' <= c && c <= 'z')) return ch; return c.charCodeAt(0) - 'a'.charCodeAt(0) + 1; }; const transformInput = () => userInput .split('') letters .map(c => convertChar(c)) .join(' '); getResult = () => userInput .split('') .map(c => convertChar(c)) .filter( c => ( typeof c !== 'string' && !isNaN(c) ) ) .reduce( (total, itm) => total + itm, 0 ); return ( <div> <div> <label htmlFor={'usrinp'}>Enter text: </label> <input id="usrinp" value={userInput} onChange={handleChange} /> </div> { userInput.length > 0 && <p>Converted text to: {transformInput()}</p> } <button onClick={() => setShowResult(true)}> Submit </button> { showResult && <p>Result is: {getResult()}</p> } </div> ); }; ReactDOM.render( <div> <h4>Transform User input text to numbers</h4> <Thingy /> </div>, document.getElementById("rd") );