Skip to content

array function push, splice doesn't trigger state change and redraw #358

Open
@kangaroolab

Description

@kangaroolab
let subnodes = van.state([]);
...
button({
                innerHTML: '+',
                onclick: () =>
                    {subnodes.push(key + '.' + (subnodes.length + 1))}
            }),

if I do above, it doesn't trigger any change

if I change onclick to

onclick: () =>
                    {subnodes.val = [...subnodes.val, (key + '.' + (subnodes.val.length + 1))]}

it works as expected.

same issue/behavior with subnodes.val.splice

any insight why push/splice doesn't work?

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