From b40d54353c0527d725ebb9835da8c4ec4bd1aeed Mon Sep 17 00:00:00 2001 From: Ivens Rocha Date: Thu, 7 Jan 2016 11:49:05 -0200 Subject: [PATCH 1/2] Fixed an error was being raised as pointed at #12 even if one follow 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. --- src/index.jsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/index.jsx b/src/index.jsx index 3ef2bdc..769c23f 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -184,7 +184,6 @@ var BootstrapForm = React.createClass({ }, propTypes: { - form: React.PropTypes.instanceOf(Form).isRequired, spinner: React.PropTypes.string }, @@ -194,11 +193,17 @@ var BootstrapForm = React.createClass({ } }, - render() { - patchForm(this.props.form) - return
- {this.renderRows()} -
+ 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() { From ba907a788fc3322c1533546ec5188b6120d8128c Mon Sep 17 00:00:00 2001 From: Ivens Rocha Date: Thu, 7 Jan 2016 11:55:27 -0200 Subject: [PATCH 2/2] Fixed an error was being raised as pointed at #12 even if one follow 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 the "required" form property on propTypes and made a validation inside render. --- src/index.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.jsx b/src/index.jsx index 769c23f..f8a82bc 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -184,6 +184,7 @@ var BootstrapForm = React.createClass({ }, propTypes: { + form: React.PropTypes.instanceOf(Form), spinner: React.PropTypes.string },