Skip to main content
InterviewHubPRO
Section Overview
Q29

Question 29 of 407

General

7%
React Core & Hooks (407 Qs)•General

Does the lazy function support named exports?

mid LevelCode ExamplereactGeneral

No, React.lazy currently supports default exports only. If the component you want to import is exported using named exports, you can create an intermediate module that re-exports it as the default, or resolve it using .then() on the dynamic import promise:

jsx
// Resolving a named export with React.lazy
const MyComponent = React.lazy(() =>
  import('./MyComponents').then(module => ({ default: module.MyComponent }))
);