react-flyd
react-flyd copied to clipboard
There should be a ReactiveClass POOL...
Maybe this issue should be in react-flyd-class. But in the use case of react-flyd-class, we usually missd the problem. And in using react-flyd, we may come across this problem frequently.
we render <div>{text$}</div>, and update with <div>{text$}</div>, I mean the parent of <div>{text$}</div> is updated, then the {text$} ( it is a reactive span element), this element will be destroyed and recreated because reactive('span') !== reactive('span').... This will consume a lot..... And besides, when we want to operate on the real DOM node, because they were recreated, the real DOM node changed...
my code of reactive is:
let pool = []
export function reactive(tag='') {
let cls = pool.find(cls => cls[0]===tag)
if (cls) {
return cls[1]
}
class ReactiveClass extends Component {
...
}
pool.push([tag, ReactiveClass])
return ReactiveClass
}