0 votes
in ReactJS by
What is dynamic import in ReactJS, explain with Example?

1 Answer

0 votes
by

You can achieve code-splitting in your app using dynamic import.

Let's take an example of addition,

  1. Normal Import
import { add } from "./math";
console.log(add(10, 20));
  1. Dynamic Import
import("./math").then((math) => {
  console.log(math.add(10, 20));
});
...