Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot handle Lazy and suspense #193

Open
Reytar opened this issue May 30, 2024 · 1 comment
Open

Cannot handle Lazy and suspense #193

Reytar opened this issue May 30, 2024 · 1 comment

Comments

@Reytar
Copy link

Reytar commented May 30, 2024

Hey,
I'm trying to use the wizard, where one of the steps is lazy load and I get this error:
"Cannot convert object to primitive value".

Code:

const Step2Lazy = lazy(() => delayForDemo(import("./Step2Lazy.tsx")));

const delayForDemo = (promise: Promise<any>) => {
  return new Promise((resolve) => {
    setTimeout(resolve, 2000);
  }).then(() => promise);
};

export const Widget: React.FC = () => {
  const [selectedCountry, setSelectedCountry] = useState<string>("");

  const handleSelectCountry = (value: string) => {
    setSelectedCountry(value);
  };

  return (
    <div>
      <Wizard footer={<Footer selectedCountry={selectedCountry} />}>
        <Step1 />
        <Suspense fallback={<p>Loading...</p>}>
          <Step2Lazy
            handleSelectCountry={handleSelectCountry}
            selectedCountry={selectedCountry}
          />
        </Suspense>
      </Wizard>
    </div>
  );
};

Error:

Uncaught TypeError: Cannot convert object to primitive value
at String ()
at chunk-QI53LHDY.js?v=9fde6873:155:22
at Array.map ()
at printWarning (chunk-QI53LHDY.js?v=9fde6873:154:39)
at error (chunk-QI53LHDY.js?v=9fde6873:142:15)
at lazyInitializer (chunk-QI53LHDY.js?v=9fde6873:920:17)
at mountLazyComponent (react-dom_client.js?v=9fde6873:14840:27)
at beginWork (react-dom_client.js?v=9fde6873:15936:22)
at HTMLUnknownElement.callCallback2 (react-dom_client.js?v=9fde6873:3672:22)
at Object.invokeGuardedCallbackDev (react-dom_client.js?v=9fde6873:3697:24)

@azakharo
Copy link

There could be many steps.
Are they all mounted at once?
Or each of them is mounted only when it becomes active?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants