0

I am trying to implement widgetbot.io into a project of mine and I am running into an issue where react is rendering the widget multiple times.

function App() {
  async function createWidget() {
    let result = await import("@widgetbot/crate");
    const Crate = await result.cdn();
    new Crate({
      server: "some-random-numbers",
      channel: "some-random-numbers",
    });
  }

  
  useEffect(() => {
    createWidget();
  }, []);

  return (
    <div className="App">
      {* content here *}
    </div>
  );
}

export default App;


I thought that by passing in an empty dependency array useEffect would only run on the initial render?

I did some print debugging and found out that the widget is being rendered twice on initial load.

Does anyone know how I can solve this issue?

DataD96
  • 301
  • 3
  • 12

0 Answers0