'Move it inside the useMemo callback. Alternatively, wrap the initialization of 'COLOR_CODES' in its own useMemo() Hook react-hooks/exhaustive-deps

Plz help me how to solve the error Move it inside the useMemo callback. Alternatively, wrap the initialization of 'COLOR_CODES' in its own useMemo() Hook react-hooks/exhaustive-deps

    const pathColor = React.useMemo(() => {
    const { alert, warning, info } = COLOR_CODES;
    if (counter <= alert.threshold) {
      return alert.color;
    } else if (counter <= warning.threshold) {
      return warning.color;
    } else {
      return info.color;
    }
  }, [counter,  COLOR_CODES]);


Sources

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

Source: Stack Overflow

Solution Source