insin/newforms

Field choices still raises React warning

Opened this issue · 1 comments

This sample gives "Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of FormRow."

This was fixed in #68, but somehow still gives warnings.

var React = require("react");
var forms = require("newforms");

var IPIN = forms.Form.extend({
    dev: forms.ChoiceField(),
});

var Thing = React.createClass({
  getInitialState: function(){
    return {form: new IPIN({controlled:true, onChange: this.forceUpdate.bind(this)})}
  },

  componentDidMount: function(){
    var fform = this.refs["ipin"].getForm();       
    fform.fields.dev.setChoices(["a", "b", "c"]);
fform.setData({}); //to force re-render
  },

  render: function(){
    return (
            <form>
                <forms.RenderForm form={this.state.form} ref="ipin" />
                <button>submit</button>
            </form>
        );
  }
});
var r = React.render(<Thing/>, document.body);

This is caused by default ErrorList rendering - note the warning disappears if you replace fform.setData({}) with this.forceUpdate().