Skip to content

Commit b229003

Browse files
Merge pull request #91 from andrewhathaway/reffix
Fix Refs
2 parents 6384d1f + dd4e7d0 commit b229003

File tree

5 files changed

+44
-20
lines changed

5 files changed

+44
-20
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
# [1.1.4](https://github.com/andrewhathaway/Winterfell/releases/tag/1.1.4) (2017-07-13)
4+
5+
**Fixed bugs:**
6+
7+
- Switch to new React Ref handling from previous ways
8+
39
# [1.1.3](https://github.com/andrewhathaway/Winterfell/releases/tag/1.1.3) (2017-05-01)
410

511
**Fixed bugs:**

dist/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ var Winterfell = (function (_React$Component) {
2222

2323
_get(Object.getPrototypeOf(Winterfell.prototype), 'constructor', this).call(this, props);
2424

25+
this.formComponent = null;
26+
2527
// Set our default values for props.
2628
var props = _.extend({
2729
schema: {
@@ -133,7 +135,11 @@ var Winterfell = (function (_React$Component) {
133135
this.setState({
134136
action: action
135137
}, function () {
136-
ReactDOM.findDOMNode(_this.refs[_this.props.ref]).submit();
138+
if (!_this.formComponent) {
139+
return;
140+
}
141+
142+
_this.formComponent.submit();
137143
});
138144
}
139145
}, {
@@ -150,7 +156,9 @@ var Winterfell = (function (_React$Component) {
150156
{ method: this.props.method,
151157
encType: this.props.encType,
152158
action: this.state.action,
153-
ref: this.props.ref,
159+
ref: function (ref) {
160+
return _this2.formComponent = ref;
161+
},
154162
className: this.state.schema.classes.form },
155163
React.createElement(
156164
'div',

dist/winterfell.min.js

Lines changed: 17 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "winterfell",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "Generate complex, validated and extendable JSON-based forms in React",
55
"main": "dist/index.js",
66
"scripts": {
@@ -33,8 +33,8 @@
3333
"babelify": "^6.3.0",
3434
"keycodez": "^1.0.0",
3535
"lodash": "^3.10.1",
36-
"react": "^15.3.0",
37-
"react-dom": "^15.3.0",
36+
"react": "^15.6.1",
37+
"react-dom": "^15.6.1",
3838
"validator": "^4.0.5"
3939
},
4040
"devDependencies": {

src/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class Winterfell extends React.Component {
99
constructor(props) {
1010
super(props);
1111

12+
this.formComponent = null;
13+
1214
// Set our default values for props.
1315
var props = _.extend({
1416
schema : {
@@ -123,8 +125,11 @@ class Winterfell extends React.Component {
123125
this.setState({
124126
action : action
125127
}, () => {
126-
ReactDOM.findDOMNode(this.refs[this.props.ref])
127-
.submit();
128+
if (!this.formComponent) {
129+
return;
130+
}
131+
132+
this.formComponent.submit();
128133
});
129134
}
130135

@@ -136,7 +141,7 @@ class Winterfell extends React.Component {
136141
<form method={this.props.method}
137142
encType={this.props.encType}
138143
action={this.state.action}
139-
ref={this.props.ref}
144+
ref={ref => this.formComponent = ref}
140145
className={this.state.schema.classes.form}>
141146
<div className={this.state.schema.classes.questionPanels}>
142147
<QuestionPanel schema={this.state.schema}

0 commit comments

Comments
 (0)