प्रतिक्रिया करने के लिए नया और ऑब्जेक्ट विशेषताओं को लूप करने का प्रयास कर रहा है लेकिन प्रतिक्रिया के बारे में शिकायत शिकायत मान्य नहीं है बच्चे, क्या कोई मुझे इस समस्या को हल करने के बारे में कुछ सलाह दे सकता है? मैंने createFragment जोड़ा है लेकिन पूरी तरह से यह सुनिश्चित नहीं है कि इसे कहां जाना है या मुझे क्या दृष्टिकोण लेना चाहिए?प्रतिक्रिया में किसी ऑब्जेक्ट को कैसे लूप करें?
जे एस
var tifs = {1: 'Joe', 2: 'Jane'};
var tifOptions = Object.keys(tifs).forEach(function(key) {
return <option value={key}>{tifs[key]}</option>
});
समारोह प्रस्तुत
render() {
const model = this.props.model;
let tifOptions = {};
if(model.get('tifs')) {
tifOptions = Object.keys(this.props.model.get('tifs')).forEach(function(key) {
return <option value={key}>{this.props.model.get('tifs')[key]}</option>
});
}
return (
<div class={cellClasses}>
<div class="grid__col-5 text--center grid__col--bleed">
<h5 class="flush text--uppercase">TIF</h5>
<select id="tif" name="tif" onChange={this.handleChange}>
{tifOptions}
</select>
</div>
</div>
);
}
सांत्वना
If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object)
मुझे इससे पहले की तरह एक ही त्रुटि मिली। '.map()' का उपयोग करना अजीब रूप से पर्याप्त मेरे लिए तय था। यह भी दिलचस्प था: http://stackoverflow.com/questions/37997893/promise-error-objects-are-not-valid-as-a-react-child –