I'm throwing an error in my loaders when response.status.ok of fetch is false. Error component is then loaded.
But my server sometimes returns 429 status code (too many requests) upon which I don't want to load an error component but instead simply do nothing, or maybe display some message but certainly without reloading the already loaded component, or redirecting, etc.
How can that be implemented?
https://codesandbox.io/s/hungry-hooks-yuucsp?file=/src/App.js

React Router cancel loader
You can check the response status code specifically for a 429 status and return any defined value back to the UI. I think the important detail here that you should return something instead of undefined. null appears to work and not throw any extraneous errors
function loader() {
  let response = imitateFetch();
  console.log(response);

  if (response.status === 429) {
    console.log(429);
    return null; // <-- return null
  }

  if (!response.ok) {
    throw "loader error";
  }
  return {};
}

but you can return anything you like, for example, change the response status to 200.
function loader() {
  let response = imitateFetch();
  console.log(response);

  if (response.status === 429) {
    console.log(429);
    response.status = 200;
    response.ok = true;
    return response;
  }

  if (!response.ok) {
    throw "loader error";
  }
  return {};
}


It's really up to your app's, or code's, specific use case what it returns and how the UI handles it.
