React & React Native

React.lazy & code splitting

Në shqip: Ngarkimi i vonuar i komponentëve

ShpjegimiSQ

React.lazy(() => import("./Paneli")) e ngarkon kodin e një komponenti vetëm kur shfaqet për herë të parë. Kështu faqja e parë hapet më shpejt, sepse s'shkarkon kodin e të gjitha faqeve njëherësh.

EnglishEN

React.lazy(() => import("./Dashboard")) loads a component's code only when it's first shown. The first page opens faster because it doesn't download every page's code at once.

Si ta mendosh

Si t'i marrësh vetëm librat e ditës në çantë, jo gjithë bibliotekën.

Lexoje në anglisht

Like packing only today's books in your bag, not the whole library.

Shembull kodijavascript

const Paneli = lazy(() => import("./Paneli.jsx"));
<Suspense fallback={<Ngarkim />}><Paneli /></Suspense>

Terma të lidhur