Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling null properties values #108

Open
jeanmw opened this issue Aug 16, 2022 · 0 comments
Open

Handling null properties values #108

jeanmw opened this issue Aug 16, 2022 · 0 comments

Comments

@jeanmw
Copy link

jeanmw commented Aug 16, 2022

      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?

@jeanmw jeanmw changed the title Handling null property values Handling null properties values Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant