Discussion about errors with block content to React and adding a serializer for a citation type in a new project.
43 replies
Last updated: Oct 4, 2021
R
Hello! New to the Slack, been using and really enjoying Sanity for a bit now. I'm having some trouble with block content to React on a new project -- is anyone around who could chat about some errors I'm getting?
Oct 1, 2021, 2:59 PM
R
Hi
user Y
! I'm using @sanity/block-content-to-reactand adding a serializer for the
citationtype that I've added in, but I keep getting
Unknown block type "undefined", please specify a serializer for it in the `serializers.types` prop
Oct 1, 2021, 3:26 PM
R
I tried two different ways of implementing the custom block within my schema and got the same error both times. Happy to share how I structured that if it's helpful.
Oct 1, 2021, 3:27 PM
Is it the whole Portable Text array? Do you see anything funky with the data if you console.log it?
Oct 1, 2021, 3:28 PM
Is it the whole Portable Text array? Do you see anything funky with the data if you console.log it?
Oct 1, 2021, 3:28 PM
R
That's part of what's interesting, the date looks pretty normal in the console log, but I don't see any
typeattached to any of the children. Could that be part of the problem?
Oct 1, 2021, 3:29 PM
The
_type: 'citation'should be on the root objects. So there might be something going on here. Are you using framework or anything?
Oct 1, 2021, 3:31 PM
R
I do! One sec, I'll push up the latest code.
Oct 1, 2021, 3:33 PM
R
I do! One sec, I'll push up the latest code.
Oct 1, 2021, 3:33 PM
R
It's on this branch here: https://github.com/throneless-tech/recoding-tech/tree/design-implementation
Oct 1, 2021, 3:34 PM
R
It's on this branch here: https://github.com/throneless-tech/recoding-tech/tree/design-implementation
Oct 1, 2021, 3:34 PM
R
Oct 1, 2021, 3:39 PM
R
Oct 1, 2021, 3:39 PM
R
Currently yes unfortunately. Would looking at the schema help? I built it here: https://github.com/throneless-tech/recoding-tech/blob/design-implementation/studio/schemas/portable_text.js
Oct 1, 2021, 3:43 PM
R
Yes! Is the structure incorrect?
Oct 1, 2021, 3:47 PM
R
Ah gotcha, thanks so much. I'll give that a try
Oct 1, 2021, 3:47 PM
I suspect it’s this pattern that you’re trying at https://www.sanity.io/guides/portable-text-internal-and-external-links
Oct 1, 2021, 3:47 PM
R
Ah yes that's exactly what I was working from
Oct 1, 2021, 3:49 PM
R
So progress, I'm getting a new error 😆
TypeError: Cannot read property 'find' of undefined
Oct 1, 2021, 3:51 PM
R
It's definitely reading other fields that I've added, like the title and even other references. And if I log the object, all the data appears to be there
Oct 1, 2021, 3:55 PM
R
It's definitely reading other fields that I've added, like the title and even other references. And if I log the object, all the data appears to be there
Oct 1, 2021, 3:55 PM
R
Now getting the error
TypeError: can't access property "find", markDefs is undefined
Oct 1, 2021, 4:02 PM
R
Now getting the error
TypeError: can't access property "find", markDefs is undefined
Oct 1, 2021, 4:02 PM
R
I need to run offline for a bit but will be back and would love to hear if you have any other ideas. Thanks so much for your help this far!
Oct 1, 2021, 4:08 PM
R
I need to run offline for a bit but will be back and would love to hear if you have any other ideas. Thanks so much for your help this far!
Oct 1, 2021, 4:08 PM
R
Now getting the error
TypeError: can't access property "find", markDefs is undefined
Oct 1, 2021, 4:02 PM
It would help to access the data. I’m not super familiar with Stackbit, and it’s not super clear to me how they handle the data fetching
Oct 1, 2021, 4:10 PM
I don’t understand what happens here 😅 https://github.com/throneless-tech/recoding-tech/blob/design-implementation/sourcebit.js#L78-L98
Oct 1, 2021, 4:10 PM
R
Haha ok totally fair, I'm not sure either. Makes sense that it could be something with stackbit, and I'll see if I can make the dataset accessible!
Oct 1, 2021, 6:18 PM
R
Haha ok totally fair, I'm not sure either. Makes sense that it could be something with stackbit, and I'll see if I can make the dataset accessible!
Oct 1, 2021, 6:18 PM
R
Hi
user Y
! Following up on this because I think I figured out the problem and am submitting a PR to stackbit. My new question though is how best to format a serializer for an annotation. Is there a recommended format for adding a mark that's a reference? I see the example usage for a mark that's a highlighter, but what if the mark is a reference to another record?Oct 4, 2021, 6:45 PM
R
Hi
user Y
! Following up on this because I think I figured out the problem and am submitting a PR to stackbit. My new question though is how best to format a serializer for an annotation. Is there a recommended format for adding a mark that's a reference? I see the example usage for a mark that's a highlighter, but what if the mark is a reference to another record?Oct 4, 2021, 6:45 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.