Loading Chunk Failed Error

745 단어 ReactReact

How to prevent your Loading chunk failed errors
medium link

recursive code to recall till attempsleft is 0

export default function componentLoader(lazyComponent, attemptsLeft) {
  return new Promise((resolve, reject) => {
    lazyComponent()
      .then(resolve)
      .catch((error) => {
        // let us retry after 1500 ms
        setTimeout(() => {
          if (attemptsLeft === 1) {
            reject(error);
            return;
          }
          componentLoader(lazyComponent, attemptsLeft - 1).then(resolve, reject);
        }, 1500);
      });
  });
}

좋은 웹페이지 즐겨찾기