Cannot convert undefined or null to object

Hi,

I’m trying to display data on a page with this

import React from 'react';
import { connect } from 'frontity';

const FlexibleContent = ({ flexibleContent, data }) => {
    return (
        <>
            {flexibleContent && flexibleContent.map((content, index) => {
                if (content.acf_fc_layout === "text_with_image")
                    return <div key={index} content={content}>Flexible content</div>;

            })}
        </>
    );
}
        
export default connect(FlexibleContent);

but I get the following error coming from the content={content} inside the

TypeError: Cannot convert undefined or null to object

I have console.logged content and it’s an object. I can’t figure out why I receive that error.

Here is the file that is causing issue and repo Bitbucket

Any help would be hugely appreciated.
Thanks,
Jeff

Hi guys,

Any idea what this could be? Any object that I pass as props is seen as undefined or null but if I console.log content or data for example they are objects and have data in them. They never result as undefined or null.

Am I missing something? Do I have to wait for the data to be fetched somehow?

Many thanks,
Jeff

This issue is now resolved, I was actually passing props to a component that was not requesting that prop yet.

The solution was to request the prop from the component.

2 Likes