79426786

Date: 2025-02-10 10:35:05
Score: 1
Natty:
Report link

The problem is that the URL you have ('/url/to/OtherComponent.js') is dynamic and could be fetched from an API. React.lazy can't directly handle dynamic URLs in this manner because it needs to resolve the module ahead of time.

Here's how you can handle this:

React.lazy only accepts a dynamic import function, which works with static module paths.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Anurag