fre icon indicating copy to clipboard operation
fre copied to clipboard

When render is called multiple times

Open kethan opened this issue 3 years ago • 3 comments

Hi, when I call render multiple times the component is attached in the dom multiple times. I have a requirement to re-render multiple times for creating custom elements.

import { render, useState } from "fre"

function App() {
  const [count, setCount] = useState(0)
  return (
    <>
      <h1>{count}</h1>
      <button onClick={() => setCount(count + 1)}>+</button>
    </>
  )
}

render(<App />, document.body)
render(<App />, document.body)
render(<App />, document.body)

kethan avatar Apr 08 '22 12:04 kethan

Fre can't reuse DOM yet, but I don't know what scenario you use custom element in?

yisar avatar Apr 08 '22 12:04 yisar

Hi here is an example I am using https://codesandbox.io/s/fre-custom-element-dzg4p8?file=/index.js

kethan avatar Apr 08 '22 16:04 kethan

Any update or solution i can implement?

kethan avatar May 17 '22 01:05 kethan