Category: WordPress

  • TypeError: b.map is not a function

    If you’re building blocks for WordPress, and the error TypeError: b.map is not a function is logged in your browser’s developer console, you may have created a SelectControl component and failed to wrap the options in brackets to create an array.

    This code will cause the error:

    			<SelectControl
    				label="Minimum Rating"
    				value={ attributes.minimumRating }
    				options={ 
    					{ label: 'Great Deal', value: 'GREAT_PRICE' },
    					{ label: 'Good Deal', value: 'GOOD_PRICE' },
    					{ label: 'Fair Deal', value: 'FAIR_PRICE' }
    				 }
    				onChange={ onChangeMinimumRating }
    			/>

    This is the correct syntax:

    			<SelectControl
    				label="Minimum Rating"
    				value={ attributes.minimumRating }
    				options={ [
    					{ label: 'Great Deal', value: 'GREAT_PRICE' },
    					{ label: 'Good Deal', value: 'GOOD_PRICE' },
    					{ label: 'Fair Deal', value: 'FAIR_PRICE' }
    				] }
    				onChange={ onChangeMinimumRating }
    			/>
  • Gravity View is_approved enumeration

    Entry approval is a Gravity View feature I use often. Even if I’m not using Gravity View on a project that needs to filter out some entries, I’ll save the same data in the $wpdb->_gf_entry_meta table to be compatible. The meta key is_approved contains one of the values in the table below.

    Entry is_approved meta values

    IconValueDefinition
    1Approved
    2Disapproved
    3No choice made/reset