Skip to content

Commit dc2b66a

Browse files
author
Marcin Szamotulski
committed
Rename: withRef && added comments.
1 parent 00d51f6 commit dc2b66a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/React.purs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,20 +300,24 @@ foreign import getRefs :: forall props state access eff.
300300
ReactThis props state ->
301301
Eff (refs :: ReactRefs (read :: Read | access) | eff) Refs
302302

303+
-- | Ref type. You can store `Ref` types on `Refs` object (which in
304+
-- | corresponds to `this.refs`). Use `ReactDOM.refToNode` if you want to
305+
-- store a `DOM.Node.Types.Node`
303306
foreign import data Ref :: Type
304307

305-
-- | Read named ref from Refs
306308
foreign import readRefImpl :: forall props state access eff.
307309
ReactThis props state ->
308310
String ->
309311
Eff (refs :: ReactRefs (read :: Read | access) | eff) (Nullable Ref)
310312

313+
-- | Read named ref from `Refs`.
311314
readRef :: forall props state access eff.
312315
ReactThis props state ->
313316
String ->
314317
Eff (refs :: ReactRefs (read :: Read | access) | eff) (Maybe Ref)
315318
readRef this name = toMaybe <$> readRefImpl this name
316319

320+
-- | Write a `Ref` to `Refs`
317321
foreign import writeRef :: forall props state access eff.
318322
ReactThis props state ->
319323
String ->

src/React/DOM/Props.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,13 @@ ref = unsafeMkProps "ref"
305305

306306
-- | You can use `writeRef` to store a reference on `Refs`.
307307
-- | ``` purescrript
308-
-- | div [ refCb (writeRef this "inputEl") ] [...]
308+
-- | div [ withRef (writeRef this "inputElement") ] [...]
309309
-- | ```
310-
refCb
310+
withRef
311311
:: forall access eff
312312
. (Ref -> Eff (refs :: ReactRefs (write :: Write | access) | eff) Unit)
313313
-> Props
314-
refCb cb = unsafeMkProps "ref" (unsafePerformEff <<< cb)
314+
withRef cb = unsafeMkProps "ref" (unsafePerformEff <<< cb)
315315

316316
rel :: String -> Props
317317
rel = unsafeMkProps "rel"

0 commit comments

Comments
 (0)