Skip to content

Modebar button click function does not update on rerender #5796

@vdgodse

Description

@vdgodse

https://codepen.io/vdgodse/pen/ExmjGLN

In plotly we can provide config as: modeBarButtonsToAdd: [
{
name: 'button1',
icon: Plotly.Icons.pencil,
direction: 'up',
click: function(gd) {
// this does not update on rerender and always holds the stale react state in closure as shown in the codepen demo
}
}],

Click on the pencil icon to see alert with realCount and staleCount. Since second click the counts diverge.

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