question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why does zoid.destroy() throw an error when it destroys components?

See original GitHub issue

I need to create a react zoid component during the render phase, based on some props where we don’t know the tag or url ahead of time. My component looks like this;

export const ZoidComponent = ({ tag, url, ...props }) => {
  const Zoid = useMemo(() => {
    zoid.destroy()
    return zoid.create({ tag, url }).driver("react", { React, ReactDOM })
  }, [tag, url])

  return Zoid ? <Zoid {...props} /> : null;
}

The component above works fine and as expected, however, there’s a niggly Uncaught Error: zoid destroyed all. I destroy before creating because if I don’t, I get the error Can not register multiple components with the same tag.

Why does it throw this error if it destroyed it successfully?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
devdiegomancommented, Jun 8, 2020

Hi @bluepnume

So, how could we update the URL of the Zoid-component that was created with a specific URL? I mean, it’s possible to update the URL of the component used in the create function from Zoid?

1reaction
bluepnumecommented, Apr 6, 2020

Fair enough 😃

That’s why I suggested setting url as a function though. Based on the props passed, you can generate totally different urls.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Error: zoid destroyed all components " error in reactjs nextjs
My solution is load the PayPal script before run create button script function loadAsync(url: string, callback: () => void) { const s ...
Read more >
Error: zoid destroyed all components " error in reactjs nextjs ...
Currently, there is an open PR that has not yet been completed/approved, but is on the way to solve this issue.
Read more >
krakenjs - Bountysource
But if the user opens the modal and quickly closes it, (seemingly, before the zoid iframe finished loading), then the following uncaught error...
Read more >
zoid - UNPKG
The CDN for zoid. ... src/component/component.js","webpack://zoid/. ... (!host) {\n throw new Error(`Can not read window host`);\n }\n\n return `${ protocol ...
Read more >
Multiple currencies support in paypal smart Button
The console throwing error Uncaught Error: Zoid destroyed all components on every switch of a radio button. Any tip or suggestion is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found