Skip to content

Commit

Permalink
Fixed an error was being raised as pointed at insin#12 even if one fo…
Browse files Browse the repository at this point in the history
…llow the docs:

    Warning: Failed propType: Required prop `form` was not specified in `BootstrapForm`. Check the render method of `App`.

As far as I see the `required` of form is only used in order to guarantee it is used between a newforms.Form tag. But if you don`t pass it, an error is raised anyway:
   Uncaught TypeError: Cannot read property `__patchedByBootstrapForm` of undefined

So I removed the mandatory form and made a validation inside render.
  • Loading branch information
Ivens Rocha committed Jan 7, 2016
1 parent f00317d commit b40d543
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ var BootstrapForm = React.createClass({
},

propTypes: {
form: React.PropTypes.instanceOf(Form).isRequired,
spinner: React.PropTypes.string
},

Expand All @@ -194,11 +193,17 @@ var BootstrapForm = React.createClass({
}
},

render() {
patchForm(this.props.form)
return <div>
{this.renderRows()}
</div>
render:function() {
if (this.props.form === undefined) {
console.error("Warning newforms-bootstrap requires to be passed between newforms.Form tags.");
return React.createElement("div", null, null);
}
else {
patchForm(this.props.form)
return React.createElement("div", null,
this.renderRows()
)
}
},

renderRows() {
Expand Down

0 comments on commit b40d543

Please sign in to comment.