Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.
This repository was archived by the owner on May 22, 2024. It is now read-only.

Dynamic Component Binding? #36

@gilbox

Description

@gilbox

I'm trying to optimize shouldComponentUpdate by only binding to the data that really matters...

Am I not supposed to use a binding whose path is always changing? For example, my render function looks something like this:

var binding = this.getDefaultBinding(),
        currentChartIndexBinding = binding.sub('currentChartIndex'),
        currentChartIndex = currentChartIndexBinding.get(),
        chartBinding = binding.sub('history').sub(currentChartIndex);

    return (
      <div className="fill">
        <FlowChart binding={ {default:chartBinding, index:currentChartIndexBinding } } />
      </div>
    )

So I am binding to currentChartIndexBinding because the chart index might change. But even if the chart index doesn't change, the data in the current chart might change which is why I bind to chartBinding.

As you would expect, currentChartIndexBinding works fine. Unfortunately, what happens is that chartBinding is always one step behind. Ie., in shouldComponentUpdateOverride, which is defined in the FlowChart component, this.getDefaultBinding().toJS() returns the previous value.

Is this a bug, or expected behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions