score:-2

Maybe useRef can help to deal with your case https://medium.com/trabe/react-useref-hook-b6c9d39e2022

score:1

const getName = () => {
    const stack = new Error().stack;
    const lines = stack.split("\n");
    const line = lines[3];
    const match = line.match(/at (.*) \(/);
    const name = match[1];
    return name;
  };

I got it using copilot...


Related Query

More Query from same tag