Elmish.React
- Package
- purescript-elmish
- Repository
- collegevine/purescript-elmish
#ReactElement Source
data ReactElement :: TypeInstantiated subtree of React DOM. JSX syntax produces values of this type.
Instances
#ReactComponent Source
data ReactComponent :: Type -> TypeThis type represents constructor of a React component with a particular
behavior. The type prameter is the record of props (in React lingo) that
this component expects. Such constructors can be "rendered" into
ReactElement via createElement.
#ReactComponentInstance Source
data ReactComponentInstance :: TypeA specific instance of a React component - i.e. an object that has state
and props properties on it.
#ValidReactProps Source
class ValidReactProps a Asserts that the given type is a valid React props structure. Currently there are three rules for what is considered "valid":
- The type must be a record.
- The types of all props must be safe to pass to JavaScript,
which is asserted via the
CanPassToJavaScriptclass. - There cannot be a prop named 'ref'. Currently we do not support React refs, and when we do, the type of that prop will have to be restricted to something special and effectful.
Instances
(RowToList r rl, ValidReactPropsRL rl, CanPassToJavaScript (Record r)) => ValidReactProps (Record r)
#ValidReactPropsRL Source
class ValidReactPropsRL (a :: RowList) Internal implementation detail of the ValidReactProps class. This has to be a
separate class due to how rows work at type level.
Instances
#ReactChildren Source
class ReactChildren a whereDescribes a type that can be used as "content" (aka "children") of a React
JSX element. The three instances below make it possible to use String and
ReactElement as children directly, without wrapping them in an array.
Members
asReactChildren :: a -> Array ReactElement
Instances
#createElement Source
createElement :: forall content props. ValidReactProps props => ReactChildren content => ReactComponent props -> props -> content -> ReactElementThe PureScript import of the React’s createElement function. Takes a
component constructor, a record of props, some children, and returns a
React DOM element.
To represent HTML data- attributes, createElement supports the
_data :: Object prop.
Example
import Elmish.HTML as H
import Foreign.Object as FO
H.div
{ _data: FO.fromHomogenous { toggle: "buttons } }
[...]
represents the <div data-toggle="buttons"> DOM element.
#createElement' Source
createElement' :: forall props. ValidReactProps props => ReactComponent props -> props -> ReactElementVariant of createElement for creating an element without children.
#renderToString Source
renderToString :: ReactElement -> String