Skip to content

There should be a ReactiveClass POOL... #6

Description

@xialvjun

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
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions