You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the textbox where we can edit the text, we have to add an option to add variables.
A variable can be denoted in the textbox by, for ex, Hello {{name}}, from {{class}} where name can be Subramani, Asil, Amal etc and class can be eca, csc like that
Hints
so what you'd have to do is just have a state variable in the format:
const[myvars,setMyVars]={textbox1: [],textbox2:[]}// where the array would have variables like name, class etc for a textbox // to keep track of variables in each textbox
Sample function to detect variables:
constcheckVariable=(currValue)=>{constregex=/{{\s*([a-zA-Z_$][a-zA-Z_$0-9]*)\s*}}/g;constmatches=currValue.match(regex);if(matches){constnewVariables=matches.map((match)=>match.replace(/{{\s*|\s*}}/g,""));// Add only unique variable names to the statesetNewHandles((prevVariables)=>{constuniqueVars=[...newSet([...newVariables])];returnuniqueVars;});}else{setNewHandles([]);}};
The text was updated successfully, but these errors were encountered:
Description
In the textbox where we can edit the text, we have to add an option to add variables.
A variable can be denoted in the textbox by, for ex, Hello {{name}}, from {{class}} where name can be Subramani, Asil, Amal etc and class can be eca, csc like that
Hints
so what you'd have to do is just have a state variable in the format:
Sample function to detect variables:
The text was updated successfully, but these errors were encountered: