Skip to content

bug: updateTab doesn't change the reference of current #732

Description

@mortalYoung

Describe the bug

I have two components named A and B. And I call updateTab on A, and render something on B. For example:

// A.tsx
const onFinish = () => {
    form.validation().then(res => {
        molecule.editor.updateTab({
            id,
            // I want to store the values of form into tab
            data:{...data,taskVariables: res}
        })
    })
}


// B.tsx
const B = connect(molecule.editor, ({current}) => {
    useEffect(() => {
         if(current.tab.data.taskVariables){
             // do something with taskVariables
         }
    }, [current])
})

But its' unfortunately to detect the changes of current.

Versions

  • OS: MacOS
  • Browser: Firefox
  • Molecule: @dtinsight/molecule 0.9.0-beta.4.2

To reproduce

Expected

=== could be used to detect the changes of current, so I can do something based on taskVariables.

Actually happening

=== couldn't detect the changes, but I find the current changed indeed. So the problem possibly is that the updateTab use Object.assign to update the current data, but don't change the reference of current.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions