I'm trying to iterate over a dictionary of arrays of nodes but am having trouble rendering the components. It compiles and builds correctly but none of the rendering is happening.
It should iterate through 'values' with the dictionary and go through every array and render the elements in the array and do that for all the arrays in the dictionary. I'm not sure why I can't seem to get that to work...
var props = {
'name' : 'form',
'timer' : 1500,
'callback' : function(id, validity, value) {console.log(id, validity, value);},
'values': {
"1": ["hello", "world"],
"2": ["", "test"],
"3": ["i", "am", "me"]
},
'hashNode' : new FormatOC.HashNode({
"__hash__":true,
"__array__":"duplicate",
"__type__":"string"
}),
}
React.render(React.createElement(HashNodeComponent, props), document.getElementById('react-component'));
hash node:
render: function() {
var that = this;
console.log("Dict:", this.state.values);
var dict = that.state.values;
return (
<div id = "form">
{Object.keys(dict).map(function(key, index) {
console.log("Arrays:", dict[key]);
dict[key].map(function(v, i) {
return (
<div>
{(that.props.hashNode.get().constructor.name === "Parent") ?
<ParentComponent
name={that.props.name + i}
key={i}
timer={that.props.timer}
callback={that.childChange}
values={v}
newParent={that.props.hashNode.get()}
/>
:
<NodeComponent
name={that.props.name + i}
key={i}
timer={that.props.timer}
callback={that.childChange}
value={v}
newNode={that.props.hashNode.get()}
/>
}
<button data-index={i} onClick={that.removeItem}>Remove
</button>
</div>
)
})
})
<button onClick={() => that.addEmptyItem()}>Add
</button>
}
</div>
)
}