mizi-lin / hulujs

hulujs
MIT License
0 stars 0 forks source link

bug: You are calling ReactDOMClient.createRoot() on a container that has already been passed to createRoot() before. Instead, call root.render() on the existing root instead if you want to update it. #16

Closed mizi-lin closed 11 months ago

mizi-lin commented 11 months ago

这个错误消息表明您正在尝试在一个已经创建了根组件的容器上创建一个新的React根组件。React只允许每个容器上创建一个根组件。 要更新现有根组件的内容,您应该调用现有根的render()方法,而不是创建一个新的根。 例如,您可以使用以下方式更新根的内容:

const root = ReactDOMClient.createRoot(container); root.render(); 而不是:

const existingRoot = ReactDOMClient.createRoot(container); ReactDOMClient.createRoot(container);