I'm new react typescript developer, here i have a code which works in 'js' 'but when changed to 'tsx' getting error: Type 'Element' is not assignable to type 'string'.ts(2322) it is pointing to 'helperTextt' error (did not find answer else where) should i do : let helperTextt:any = ""; ?
any suggestions ?
let helperTextt = "";
if (event.target.id === "hostname") {
if (!HOSTNAME_REGEX.test(event.target.value)) {
helperTextt = (
<Trans i18nKey="form.formData.hostNameError">
Invalid Host name
</Trans>
);
errorr = true;
}
}
helperTextt
then you should type it aslet helperTextt: React.Element
(or whatever the concrete type is). – TunerReactElement
is exported as named export from thereact
package. – Tuner