Skip to content

How to properly redefine a cell? #174

Description

@btheado

I'm using this code to clear notebook-kit variables between redefining a cell:

const clearCellVariables = cell => {
  cell.variables.forEach(variable => variable.delete());
  cell.variables = [];
};

However, when the cell value changes from an javascript expression to another javascript expression, the output shows the string "undefined". When changing from an expression to a statement or vice versa it displays the proper value.

I have an example notebook (using embedded notebook-kit library) with the full code illustrating the problem at:

https://new.observablehq.com/@btheado/notebook-kit-clear-variables-test

Am I doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions