For some reason after the first time onChange doesn't run again.
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
if (regex.test(e.target.value) === true) {
setFen(e.target.value);
chess.load(e.target.value);
}
}}
this is the code, I check a regex expression and change the state only if the condition is met. I've tried checking with a bunch of console.logs and it just fires the first time.. This is inside a Ant Design Input component. Hope I was clear enough, ask me if you need more info!
Edit: Okay I solved: basically I've checked my regex behaviour and tried removing /g and now everything works fine. Apparently with global flag, it forwards the regex's internal index to the last found position + 1 (in case of hello, that'd be 5) and only once it tests false, will it reset back to 0.