Skip to content

Avoid reconciliation, alternative component interface #13396

@andrew-aladev

Description

@andrew-aladev

Hello. I want to ask a question about a way to avoid reconciliation process.

Today I can see the following process:

  1. Component wants to re-render.
  2. Component render method provides new virtual dom.
  3. Some react diff library tries to find some non-optimal way to morph old virtual dom into new one.

Please fix me if I am wrong, I am not familiar with react codebase.

I can see an information in docs:

you don’t have to worry about exactly what changes on every update

But your solution has complexity about O(n) or even worse, so user should care about what changes sometimes. When user knows what changed he will be able to provide O(log n) or even O(1) solution.

For example I am working with huge data list and I am receiving information from websocket about how to morph my list: append/prepend, remove, swap items, etc. I don't want to render huge component list and run reconciliation process for each mutation. I can tell virtual dom how to morph efficiently.

append

Is there a way for user to provide morph method? I can imagine some api like:

// render is not defined

morph(component) {
  if (...) {
    component.append(<Item />);
  } else {
    (<Item />).prependTo(component.find({ key: '5' }));
  }
}

Do you have any plans to implement it? Thank you. Please feel free to ask any questions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions