NotionX / NotionX/react-notion-x

TypeError: can`t convert undefined to object

Open
#435 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5.4k
Forks
645
PR merge metrics
No merged PRs in 30d

Description

Description

TypeError raised when using the NotionRenderer.

The data loads correctly from the page using

const recordMap  = await notion.getPage(params.params.pageID);

The data returned looks like this:

    {"block":{"b11a9ea3-ca3e-4470-9162-6ff8b2e39e36":{"role":"reader","value":{"id":"b11a9ea3-ca3e-4470-9162-6ff8b2e39e36","version":118,"type":"page","properties":{"title":[["Simple"]]},"content":["1b81b3e2-975f-4913-b605-dd6f43ac4685","1b69ff95-3895-468c-a9ca-94e5c53a2514","b7054860-87a5-44e3-acc0-1aeffa83c119","8a2dbe13-d3c7-455e-8480-cd6bd714c94d","762bac2c-2444-4343-8b8f-3317680038bd","862b0a5b-f432-48ba-8f4f-63369e8c00ea","702dbd51-e174-441e-8d8b-7dbd9c1f8512","a3ffe744-30c5-43b6-bfba-08aafd514ca3","a1c69dc3-d8f6-4a95-9e08-6fb3cdb57611","8c167923-9ead-4ad3-bb55-68d044a6b51f","5790c16d-a022-4332-bcf3-d3bd75128c33"],"format":{"page_font":"serif","page_full_width":false,"copied_from_pointer":{"id":"6ded6a29-8ac0-4a6c-84fb-877f6e37bdac","table":"block","spaceId":"35dee953-6b7c-449f-84f6-b47e8439080b"},"page_cover_position":0.5},"permissions":[{"role":"reader","type":"public_permission","added_timestamp":1676416752478}],"created_by":"2dcbe436-2aba-45bb-a3d4-a245488b637d","created_time":1675627725884,"last_edited_by":"2dcbe436-2aba-45bb-a3d4-a245488b637d","last_edited_time":1676418755952,"parent_id":"86713077-f788-4fbe-9663-1dd23d9c35e3","parent_table":"block","alive":true,"copied_from":"6ded6a29-8ac0-4a6c-84fb-877f6e37bdac","created_by_table":"notion_user","created_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","last_edited_by_table":"notion_user","last_edited_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","space_id":"35dee953-6b7c-449f-84f6-b47e8439080b"}},"1b81b3e2-975f-4913-b605-dd6f43ac4685":{"role":"reader","value":{"id":"1b81b3e2-975f-4913-b605-dd6f43ac4685","version":5,"type":"text","created_time":1676305740598,"last_edited_time":1676305740604,"parent_id":"b11a9ea3-ca3e-4470-9162-6ff8b2e39e36","parent_table":"block","alive":true,"created_by_table":"notion_user","created_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","last_edited_by_table":"notion_user","last_edited_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","space_id":"35dee953-6b7c-449f-84f6-b47e8439080b"}},"1b69ff95-3895-468c-a9ca-94e5c53a2514":{"role":"reader","value":{"id":"1b69ff95-3895-468c-a9ca-94e5c53a2514","version":5,"type":"text","properties":{"title":[["FEBRUARY 15, 2018"]]},"format":{"block_color":"gray","copied_from_pointer":{"id":"1994b56b-ded7-432d-8c0e-e6b4c0a3c7bf","table":"block","spaceId":"35dee953-6b7c-449f-84f6-b47e8439080b"}},"created_time":1675627725886,"last_edited_time":1676417593855,"parent_id":"b11a9ea3-ca3e-4470-9162-6ff8b2e39e36","parent_table":"block","alive":true,"copied_from":"1994b56b-ded7-432d-8c0e-e6b4c0a3c7bf","created_by_table":"notion_user","created_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","last_edited_by_table":"notion_user","last_edited_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","space_id":"35dee953-6b7c-449f-84f6-b47e8439080b"}},"b7054860-87a5-44e3-acc0-1aeffa83c119":{"role":"reader","value":{"id":"b7054860-87a5-44e3-acc0-1aeffa83c119","version":7,"type":"text","created_time":1676313886556,"last_edited_time":1676417593855,"parent_id":"b11a9ea3-ca3e-4470-9162-6ff8b2e39e36","parent_table":"block","alive":true,"created_by_table":"notion_user","created_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","last_edited_by_table":"notion_user","last_edited_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","space_id":"35dee953-6b7c-449f-84f6-b47e8439080b"}},"8a2dbe13-d3c7-455e-8480-cd6bd714c94d":{"role":"reader","value":{"id":"8a2dbe13-d3c7-455e-8480-cd6bd714c94d","version":99,"type":"text","properties":{"title":[["A simple template for a blog, .."]]},"format":{"block_color":"gray","copied_from_pointer":{"id":"c6b4a097-63a1-47d4-a0e6-f1ee83ee81b5","table":"block","spaceId":"35dee953-6b7c-449f-84f6-b47e8439080b"}},"created_by":"7c74a801-7cb5-4914-bbbe-2b18cd1ced76","created_time":1675627725884,"last_edited_by":"7c74a801-7cb5-4914-bbbe-2b18cd1ced76","last_edited_time":1676417688589,"parent_id":"b11a9ea3-ca3e-4470-9162-6ff8b2e39e36","parent_table":"block","alive":true,"copied_from":"c6b4a097-63a1-47d4-a0e6-f1ee83ee81b5","created_by_table":"notion_user","created_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","last_edited_by_table":"notion_user","last_edited_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","space_id":"35dee953-6b7c-449f-84f6-b47e8439080b"}},"762bac2c-2444-4343-8b8f-3317680038bd":{"role":"reader","value":{"id":"762bac2c-2444-4343-8b8f-3317680038bd","version":9,"type":"image","properties":{"source":[["https://images.unsplash.com/photo-1583146191066-dd148554b72b?ixlib=rb-4.0.3&q=80&fm=jpg&crop=entropy&cs=tinysrgb"]]},"format":{"block_width":720,"display_source":"https://images.unsplash.com/photo-1583146191066-dd148554b72b?ixlib=rb-4.0.3&q=80&fm=jpg&crop=entropy&cs=tinysrgb","block_full_width":false,"block_page_width":true},"created_time":1676417643408,"last_edited_time":1676417720618,"parent_id":"b11a9ea3-ca3e-4470-9162-6ff8b2e39e36","parent_table":"block","alive":true,"created_by_table":"notion_user","created_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","last_edited_by_table":"notion_user","last_edited_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","space_id":"35dee953-6b7c-449f-84f6-b47e8439080b"}},"862b0a5b-f432-48ba-8f4f-63369e8c00ea":{"role":"reader","value":{"id":"862b0a5b-f432-48ba-8f4f-63369e8c00ea","version":43,"type":"sub_sub_header","properties":{"title":[["Some additional info"]]},"created_time":1676417699349,"last_edited_time":1676417703501,"parent_id":"b11a9ea3-ca3e-4470-9162-6ff8b2e39e36","parent_table":"block","alive":true,"created_by_table":"notion_user","created_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","last_edited_by_table":"notion_user","last_edited_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","space_id":"35dee953-6b7c-449f-84f6-b47e8439080b"}},"702dbd51-e174-441e-8d8b-7dbd9c1f8512":{"role":"reader","value":{"id":"702dbd51-e174-441e-8d8b-7dbd9c1f8512","version":31,"type":"text","properties":{"title":[["adandknakdnad"]]},"created_time":1676417703919,"last_edited_time":1676417706161,"parent_id":"b11a9ea3-ca3e-4470-9162-6ff8b2e39e36","parent_table":"block","alive":true,"created_by_table":"notion_user","created_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","last_edited_by_table":"notion_user","last_edited_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","space_id":"35dee953-6b7c-449f-84f6-b47e8439080b"}},"a3ffe744-30c5-43b6-bfba-08aafd514ca3":{"role":"reader","value":{"id":"a3ffe744-30c5-43b6-bfba-08aafd514ca3","version":35,"type":"text","properties":{"title":[["a;dknakdnakdnad"]]},"created_time":1676417706352,"last_edited_time":1676417707686,"parent_id":"b11a9ea3-ca3e-4470-9162-6ff8b2e39e36","parent_table":"block","alive":true,"created_by_table":"notion_user","created_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","last_edited_by_table":"notion_user","last_edited_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","space_id":"35dee953-6b7c-449f-84f6-b47e8439080b"}},"a1c69dc3-d8f6-4a95-9e08-6fb3cdb57611":{"role":"reader","value":{"id":"a1c69dc3-d8f6-4a95-9e08-6fb3cdb57611","version":33,"type":"text","properties":{"title":[["akdnakdnakdnad"]]},"created_time":1676417707853,"last_edited_time":1676417708894,"parent_id":"b11a9ea3-ca3e-4470-9162-6ff8b2e39e36","parent_table":"block","alive":true,"created_by_table":"notion_user","created_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","last_edited_by_table":"notion_user","last_edited_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","space_id":"35dee953-6b7c-449f-84f6-b47e8439080b"}},"8c167923-9ead-4ad3-bb55-68d044a6b51f":{"role":"reader","value":{"id":"8c167923-9ead-4ad3-bb55-68d044a6b51f","version":27,"type":"text","properties":{"title":[["akdnakdnakd"]]},"created_time":1676417709109,"last_edited_time":1676417709943,"parent_id":"b11a9ea3-ca3e-4470-9162-6ff8b2e39e36","parent_table":"block","alive":true,"created_by_table":"notion_user","created_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","last_edited_by_table":"notion_user","last_edited_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","space_id":"35dee953-6b7c-449f-84f6-b47e8439080b"}},"5790c16d-a022-4332-bcf3-d3bd75128c33":{"role":"reader","value":{"id":"5790c16d-a022-4332-bcf3-d3bd75128c33","version":5,"type":"text","created_time":1676417710270,"last_edited_time":1676417710272,"parent_id":"b11a9ea3-ca3e-4470-9162-6ff8b2e39e36","parent_table":"block","alive":true,"created_by_table":"notion_user","created_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","last_edited_by_table":"notion_user","last_edited_by_id":"f7f57127-33a4-4167-8b97-1215b41645f7","space_id":"35dee953-6b7c-449f-84f6-b47e8439080b"}}},"space":{},"collection":{},"collection_view":{},"notion_user":{},"collection_query":{},"signed_urls":{}}

In trying to debug the issue, I created a myRecordMap type to determine the conflict.
I get this from the editor:

Type 'myRecordMap' is not assignable to type 'ExtendedRecordMap'.
Types of property 'collection' are incompatible.
Type 'Collection' is not assignable to type 'CollectionMap'.
Type 'undefined' is not assignable to type 'NotionMap<Collection>'.

Apologies my Typescript is not as good to debug further.

Notion Test Page ID

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the TypeError with the linked public Notion test page and the recordMap returned by notion.getPage, then inspect the NotionRenderer entry point and its ExtendedRecordMap typing. Done means the test page renders without the undefined-to-object error and the supplied record map satisfies the renderer's expected type.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.