mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
Add hot fix from AD-1313 for using refs in properties
https://github.com/ascribe/onion/blob/AD-1313-Attach-thumbnail-to-piece- in-register-form/js/components/ascribe_forms/form.js
This commit is contained in:
parent
328d60b279
commit
9c64cf2b80
@ -238,7 +238,15 @@ let Form = React.createClass({
|
||||
renderChildren() {
|
||||
return ReactAddons.Children.map(this.props.children, (child, i) => {
|
||||
if (child) {
|
||||
return ReactAddons.addons.cloneWithProps(child, {
|
||||
// Since refs will be overwritten by this functions return statement,
|
||||
// we still want to be able to define refs for nested `Form` or `Property`
|
||||
// children, which is why we're upfront simply invoking the callback-ref-
|
||||
// function before overwriting it.
|
||||
if(typeof child.ref === 'function' && this.refs[child.props.name]) {
|
||||
child.ref(this.refs[child.props.name]);
|
||||
}
|
||||
|
||||
return React.cloneElement(child, {
|
||||
handleChange: this.handleChangeChild,
|
||||
ref: child.props.name,
|
||||
key: i,
|
||||
|
Loading…
Reference in New Issue
Block a user