Can React data fetching be done without useEffect or any libraries with ORVA Consultant, Richard

Поделиться
HTML-код
  • Опубликовано: 21 дек 2024

Комментарии • 1

  • @onlinenk13
    @onlinenk13 14 дней назад

    It's an interesting approach to prefetch data, but I believe you should place the window.addEventListener call inside a useEffect. Since it's an effect, it will add the event listener on every re-render, which can become problematic. For a large application with many modules to manage, this method may not scale well. You might end up prefetching data unnecessarily, even when it’s not needed. Prefetching should be reserved for specific use cases, not applied to all the data being handled.