Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/ReactDOM.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ module ReactDOM
, findDOMNode
, renderToString
, renderToStaticMarkup
, refToNode
) where

import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Uncurried (runEffFn1, EffFn4, EffFn1, runEffFn4)
import DOM (DOM)
import DOM.Node.Types (Element, Node)
import Data.Function.Uncurried (runFn1, Fn1)
import Data.Maybe (Maybe(..))
import DOM (DOM)
import DOM.Node.Types (Element)
import React (ReactElement, ReactComponent)
import Data.Nullable (Nullable, toMaybe)
import React (ReactElement, ReactComponent, Ref)
import Unsafe.Coerce (unsafeCoerce)

-- | Render a React element in a document element. Returns Nothing for stateless components.
render
Expand Down Expand Up @@ -66,3 +69,9 @@ foreign import findDOMNodeImpl
foreign import renderToStringImpl :: Fn1 ReactElement String

foreign import renderToStaticMarkupImpl :: Fn1 ReactElement String

refToNode :: Nullable Ref -> Maybe Node
refToNode ref = toMaybe (coerce ref)
where
coerce :: Nullable Ref -> Nullable Node
coerce = unsafeCoerce