Safe Haskell | None |
---|---|
Language | Haskell2010 |
Glazier.React.Element
Description
HtmlT
inspired monad for creating ReactElement
s
Synopsis
- data ReactElement
- unsafeCoerceElement :: JSVal -> ReactElement
- mkBranchElement :: JSRep -> [Property] -> [ReactElement] -> IO ReactElement
- mkLeafElement :: JSRep -> [Property] -> IO ReactElement
- textElement :: JSString -> ReactElement
- mkCombinedElements :: [ReactElement] -> IO ReactElement
Documentation
data ReactElement Source #
NB. No FromJS provided. See unsafeCoerceElement
below.
Instances
unsafeCoerceElement :: JSVal -> ReactElement Source #
Unfortunately, ReactJS did not export an easy way to check if something is a ReactElement, although they do so in the internal code with REACT_ELEMENT_TYPE. This function allow coercing a ReactElement from a JSVal and is named unsafe as a reminder that the coersion is unchecked. This function is required when receiving ReactElement from javascript (eg in a callback) or to interface with foreign React Elements.
mkBranchElement :: JSRep -> [Property] -> [ReactElement] -> IO ReactElement Source #
Create a react element (with children) from a HashMap of properties
mkLeafElement :: JSRep -> [Property] -> IO ReactElement Source #
Create a react element (with no children) from a HashMap of properties
textElement :: JSString -> ReactElement Source #
Not an IO action because JSString is immutable
mkCombinedElements :: [ReactElement] -> IO ReactElement Source #
React only allows a single top most element.
Provide a handly function to wrap a list of ReactElements inside a div
if required.
If there is only one element in the list, then nothing is changed.