import React, { useState, ReactElement } from "react"; import { createRoot } from "react-dom/client"; import IntlTelInput from "../src/intl-tel-input/reactWithUtils"; const errorMap = [ "Invalid number", "Invalid country code", "Too short", "Too long", "Invalid number", ]; const App = (): ReactElement => { const [isValid, setIsValid] = useState(null); const [number, setNumber] = useState(null); const [errorCode, setErrorCode] = useState(null); const [notice, setNotice] = useState(null); const handleSubmit = (): void => { if (isValid) { setNotice(`Valid number: ${number}`); } else { const errorMessage = errorMap[errorCode || 0] || "Invalid number"; setNotice(`Error: ${errorMessage}`); } }; return (
{notice &&
{notice}
} ); }; const container = document.getElementById("app"); if (container) { const root = createRoot(container); root.render(); }