Skip to content

Handling null properties values #108

Open
@jeanmw

Description

@jeanmw
      case "video":
        var value = block.value;
        return /*#__PURE__*/createElement("figure", {
          className: "notion-asset-wrapper",
          style: value.format !== undefined ? {
            width: value.format.block_width
          } : undefined
        }, /*#__PURE__*/createElement(Asset, {
          block: block,
          mapImageUrl: mapImageUrl
        }), value.properties.caption && /*#__PURE__*/createElement("figcaption", {
          className: "notion-image-caption"
        }, renderChildText(value.properties.caption)));

This generated block in react-notion.esm.js is failing when properties are null. Properties are not always present in this case and therefore there can be a failure here with .caption in the chain. I'm not sure the best way to handle this - is the onus on the notion doc creator to ensure no null properties values? (this could happen if an unfinished video component was inserted in a doc and mistakenly forgotten about).

Should properties be required on ContentValueType? on All values?
Should properties be required? Can we make them nullable, or is that an antipattern?

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