Linking to Content Relationship fields

Hi, I need a little bit of assistance figuring out how I can display my Content relationship field content.

    const [doc, setData] = useState(null);
    useEffect(() => {
        const fetchData = async () => {
            const response = await Client.query(
      'document.type', 'hero_panel'),
            ).then((res) => {
            // console.log(doc);
            return response;
    }, [doc]);

    const Panel = () => {
        return (
                {/* <h1>{}</h1> */}
                {/* <h2>{[0].primary.basic_text}</h2> */}
                {/* <img alt='random' src={} /> */}

    return <Fragment>{doc ? <Panel /> : <div>No content</div>}</Fragment>;

I have a repeatable content type called 'hero_panels' and I have various fields such as images etc...

I have a singular content type called 'hero_panel' and in there I have a field called 'hero_link' that I want to inject my 'hero_panels', but I just can't seem to figure it out. I also seem to be getting this error:

Could not get the stack frames of error: TypeError: Cannot read property 'length' of null

Any help would be appreciated.

Hello @nick.toye

Welcome to the Prismic Forum.

After looking at your Prismic predicates query, I found that It needs some refactoring. This query should be like that:

const response = await Client.query(['document.type', 'hero_panel'),'my.hero_panel.hero_link', 'YHBfMREAACIAFeyw')

You need to follow this documentation.

Let me know if you have further questions.



Ah, I thought I tried that. Well that seems to work now, or at least I get less errors.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.