diff --git a/src/React.js b/src/React.js index c6e8308..84da9c5 100644 --- a/src/React.js +++ b/src/React.js @@ -43,8 +43,7 @@ exports.getChildren = getChildren; function readRefImpl (this_) { return function(name) { return function() { - var refs = this_.refs || {}; - return refs[name]; + return this_[name]; } } } @@ -54,9 +53,7 @@ function writeRef(this_) { return function(name) { return function(node) { return function() { - var refs = this_.refs || {}; - refs[name] = node; - this_.refs = refs; + this_[name] = node; return {}; } } diff --git a/src/React/DOM/Props.purs b/src/React/DOM/Props.purs index d67e968..4af5349 100644 --- a/src/React/DOM/Props.purs +++ b/src/React/DOM/Props.purs @@ -301,13 +301,16 @@ radioGroup = unsafeMkProps "radioGroup" readOnly :: Boolean -> Props readOnly = unsafeMkProps "readOnly" +-- | You can use `ref` to store a reference on `this.refs`. +-- | To access the stored reference, `getRefs` can then be used. ref :: String -> Props ref = unsafeMkProps "ref" --- | You can use `writeRef` to store a reference on `Refs`. +-- | You can use `writeRef` to store a reference on `this`. -- | ```purescript -- | div [ withRef (writeRef this "inputElement") ] [...] -- | ``` +-- | To access the stored reference, `readRef` can then be used. withRef :: forall access eff . (Nullable Ref -> Eff (refs :: ReactRefs (write :: Write | access) | eff) Unit)