Make WordPress Core

Changes between Version 1 and Version 2 of Ticket #47692, comment 18


Ignore:
Timestamp:
05/20/2020 04:40:08 PM (4 years ago)
Author:
Lwangaman
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #47692, comment 18

    v1 v2  
    4444{{{#!javascript
    4545let favouriteFoodsSelectOptions = [
    46         { value: "Vegetables",  label: [
     46        { label: "Vegetables",  value: [
    4747                                        { value: "peas",        label: "Green Peas" }
    4848                                        { value: "carrots",     label: "Carrots" },
    4949                                ]
    5050        },
    51         { value: "Meats",               label: [
     51        { label: "Meats",       value: [
    5252                                        { value: "chicken",     label: "Grilled chicken breast" },
    5353                                        { value: "turkey",      label: "Roasted turkey" },
    5454                                ]
    5555        },
    56         { value: "Fruits",      label: [
     56        { label: "Fruits",      value: [
    5757                                        { value: "apples",      label: "Red apples" },
    5858                                        { value: "oranges",     label: "Oranges" },
    5959                                ]
    6060        },
    61         { value: "Desserts",    label: [
     61        { label: "Desserts",    value: [
    6262                                        { value: "chocolate",   label: "Chocolate" },
    6363                                        { value: "pudding",     label: "Tapioca pudding" },
     
    6868}}}
    6969
    70 But this doesn't work, it generates an error:
     70But this doesn't work, I just see the labels in the rendered **select**, no **optgroup**s and no **value**s.
    7171
    72 **''Objects are not valid as a React child (found: object with keys {value, label}). If you meant to render a collection of children, use an array instead.''**
    7372
    7473There must be another intermediate file somewhere that translates between react components and {{{\WP_Customize_Manager::render_control_templates()}}}