11-- | This module defines helper functions for creating virtual DOM elements
22-- | safely.
33-- |
4- -- | Note: DOM element props are provided as records, and checked using `Union`
5- -- | constraints. This means that we don't need to provide all props, but any we
6- -- | do provide must have the correct types.
4+ -- | __* Note:* DOM element props are provided as records, and checked using `Union`
5+ -- | constraints. This means that we don't need to provide all props, but any we
6+ -- | do provide must have the correct types.__
77
88module React.Basic.DOM
99 ( module Internal
@@ -38,15 +38,15 @@ import Web.DOM (Element, Node)
3838-- | Render or update/re-render a component tree into
3939-- | a DOM element.
4040-- |
41- -- | Note: Relies on `ReactDOM.render`
41+ -- | __* Note:* Relies on `ReactDOM.render`__
4242render :: JSX -> Element -> Effect Unit
4343render jsx node = render' jsx node (pure unit)
4444
4545-- | Render or update/re-render a component tree into
4646-- | a DOM element. The given Effect is run once the
4747-- | DOM update is complete.
4848-- |
49- -- | Note: Relies on `ReactDOM.render`
49+ -- | __* Note:* Relies on `ReactDOM.render`__
5050render' :: JSX -> Element -> Effect Unit -> Effect Unit
5151render' = runEffectFn3 render_
5252
@@ -56,9 +56,9 @@ foreign import render_ :: EffectFn3 JSX Element (Effect Unit) Unit
5656-- | a DOM element, attempting to reuse the existing
5757-- | DOM tree.
5858-- |
59- -- | Note: Relies on `ReactDOM.hydrate`, generally only
59+ -- | __* Note:* Relies on `ReactDOM.hydrate`, generally only
6060-- | used with `ReactDOMServer.renderToNodeStream` or
61- -- | `ReactDOMServer.renderToString`
61+ -- | `ReactDOMServer.renderToString`__
6262hydrate :: JSX -> Element -> Effect Unit
6363hydrate jsx node = hydrate' jsx node (pure unit)
6464
@@ -67,9 +67,9 @@ hydrate jsx node = hydrate' jsx node (pure unit)
6767-- | DOM tree. The given Effect is run once the
6868-- | DOM update is complete.
6969-- |
70- -- | Note: Relies on `ReactDOM.hydrate`, generally only
70+ -- | __* Note:* Relies on `ReactDOM.hydrate`, generally only
7171-- | used with `ReactDOMServer.renderToNodeStream` or
72- -- | `ReactDOMServer.renderToString`
72+ -- | `ReactDOMServer.renderToString`__
7373hydrate' :: JSX -> Element -> Effect Unit -> Effect Unit
7474hydrate' = runEffectFn3 hydrate_
7575
@@ -79,7 +79,7 @@ foreign import hydrate_ :: EffectFn3 JSX Element (Effect Unit) Unit
7979-- | rendered into the given element. Returns `true`
8080-- | if an app existed and was unmounted successfully.
8181-- |
82- -- | Note: Relies on `ReactDOM.unmountComponentAtNode`
82+ -- | __* Note:* Relies on `ReactDOM.unmountComponentAtNode`__
8383unmount :: Element -> Effect Boolean
8484unmount = runEffectFn1 unmountComponentAtNode_
8585
@@ -89,7 +89,10 @@ foreign import unmountComponentAtNode_ :: EffectFn1 Element Boolean
8989-- | instance, or an Error if no node was found or the given
9090-- | instance was not mounted.
9191-- |
92- -- | Note: Relies on `ReactDOM.findDOMNode`
92+ -- | __*Note:* This function can be *very* slow -- prefer
93+ -- | `React.Basic.DOM.Components.Ref` where possible__
94+ -- |
95+ -- | __*Note:* Relies on `ReactDOM.findDOMNode`__
9396findDOMNode :: ReactComponentInstance -> Effect (Either Error Node )
9497findDOMNode instance_ = try do
9598 node <- runEffectFn1 findDOMNode_ instance_
@@ -115,7 +118,7 @@ text = unsafeCoerce
115118-- | Create a value of type `CSS` (which can be provided to the `style` property)
116119-- | from a plain record of CSS attributes.
117120-- |
118- -- | E.g.
121+ -- | For example:
119122-- |
120123-- | ```
121124-- | div { style: css { padding: "5px" } } [ text "This text is padded." ]
@@ -125,7 +128,7 @@ css = unsafeCoerce
125128
126129-- | Merge styles from right to left. Uses `Object.assign`.
127130-- |
128- -- | E.g.
131+ -- | For example:
129132-- |
130133-- | ```
131134-- | style: mergeCSS [ (css { padding: "5px" }), props.style ]
0 commit comments