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 }
/>