'call same function inside function react

Hey I'm trying to see a way I can call a function inside the same function but I'm getting an ESLint error when I do 'function' this was used before it was defined. no-use-before-define. There is a purpose I'm doing this when I call function a based on response I need to trigger 'b' if response is not satisfied then I need to call 'a' again

const a = () => {
  b();
}

const b = () => {
  a();
}


Solution 1:[1]

Disable the lint for that line, then, with e.g.

const a = () => {
  // eslint-disable-next-line no-use-before-define
  b();
}

It's just a stylistic warning.

Solution 2:[2]

To have dependent functions despite no-use-before-define, you could use callback functions.

Assuming you call function a first - pass function b as an argument to function a, then invoke that argument there to call function b.

const a = (functionB) => {
  functionB();
}

const b = () => {
  a();
}

a(b);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AKX
Solution 2