React
- Package
- purescript-react
- Repository
- purescript-contrib/purescript-react
This module defines foreign types and functions which wrap React's functionality.
#ReactElement Source
#ReactComponent Source
data ReactComponentA mounted react component
#ReactUnusedSnapshot Source
data ReactUnusedSnapshot#SyntheticEventHandler Source
type SyntheticEventHandler event = EffectFn1 event Unit#Render Source
type Render = Effect ReactElementA render effect.
#ComponentWillMount Source
type ComponentWillMount = Effect UnitA component will mount effect.
#ComponentDidMount Source
type ComponentDidMount = Effect UnitA component did mount effect.
#ComponentDidCatch Source
type ComponentDidCatch = Error -> { componentStack :: String } -> Effect UnitA component did catch effect.
#ComponentWillReceiveProps Source
type ComponentWillReceiveProps props = props -> Effect UnitA component will receive props function.
#ShouldComponentUpdate Source
type ShouldComponentUpdate props state = props -> state -> Effect BooleanA should component update function.
#ComponentWillUpdate Source
type ComponentWillUpdate props state = props -> state -> Effect UnitA component will update function.
#ComponentDidUpdate Source
type ComponentDidUpdate props state snapshot = props -> state -> snapshot -> Effect UnitA component did update function.
#GetSnapshotBeforeUpdate Source
type GetSnapshotBeforeUpdate props state snapshot = props -> state -> Effect snapshot#ComponentWillUnmount Source
type ComponentWillUnmount = Effect UnitA component will unmount effect.
#ReactSpecRequired Source
type ReactSpecRequired :: Type -> Row Type -> Row Typetype ReactSpecRequired state r = (render :: Render, state :: state | r)
Required fields for constructing a ReactClass.
#ReactSpecUnsafe Source
type ReactSpecUnsafe :: Type -> Type -> Row Type -> Row Typetype ReactSpecUnsafe props state r = (unsafeComponentWillMount :: ComponentWillMount, unsafeComponentWillReceiveProps :: ComponentWillReceiveProps props, unsafeComponentWillUpdate :: ComponentWillUpdate props state | r)
#ReactSpecOptional Source
type ReactSpecOptional :: Type -> Type -> Type -> Row Type -> Row Typetype ReactSpecOptional props state snapshot r = (componentDidCatch :: ComponentDidCatch, componentDidMount :: ComponentDidMount, componentDidUpdate :: ComponentDidUpdate props state snapshot, componentWillUnmount :: ComponentWillUnmount, getSnapshotBeforeUpdate :: GetSnapshotBeforeUpdate props state snapshot | ReactSpecUnsafe props state r)
Optional fields for constructing a ReactClass.
#ReactSpecShouldComponentUpdate Source
type ReactSpecShouldComponentUpdate :: Type -> Type -> Row Typetype ReactSpecShouldComponentUpdate props state = (shouldComponentUpdate :: ShouldComponentUpdate props state)
#ReactSpecAll Source
type ReactSpecAll :: Type -> Type -> Type -> Row Typetype ReactSpecAll props state snapshot = (ReactSpecRequired state) + (ReactSpecOptional props state snapshot) + (ReactSpecShouldComponentUpdate props state)
#ReactSpecPure Source
type ReactSpecPure :: Type -> Type -> Type -> Row Typetype ReactSpecPure props state snapshot = (ReactSpecRequired state) + (ReactSpecOptional props state snapshot ())
#ReactClassConstructor Source
type ReactClassConstructor :: Type -> Type -> Row Type -> Typetype ReactClassConstructor props state r = ReactThis props state -> Effect (Record r)
The signature for a ReactClass constructor. A constructor takes the
ReactThis context and returns a record with appropriate lifecycle
methods.
#ReactComponentSpec Source
class ReactComponentSpec :: Type -> Type -> Type -> Row Type -> Row Type -> Constraintclass ReactComponentSpec props state snapshot (given :: Row Type) (spec :: Row Type)
Instances
(Union given (ReactSpecAll props state ReactUnusedSnapshot) spec, Nub spec (ReactSpecAll props state snapshot)) => ReactComponentSpec props state snapshot given spec
#ReactPureComponentSpec Source
class ReactPureComponentSpec :: Type -> Type -> Type -> Row Type -> Row Type -> Constraintclass ReactPureComponentSpec props state snapshot (given :: Row Type) (spec :: Row Type)
Instances
(Union given (ReactSpecPure props state ReactUnusedSnapshot) spec, Nub spec (ReactSpecPure props state snapshot)) => ReactPureComponentSpec props state snapshot given spec
#component Source
component :: forall props state snapshot given spec. ReactComponentSpec (Record props) (Record state) snapshot given spec => String -> ReactClassConstructor (Record props) (Record state) given -> ReactClass (Record props)Creates a ReactClass inherited from React.Component.
#componentWithDerivedState Source
componentWithDerivedState :: forall props state snapshot given spec. ReactComponentSpec (Record props) (Record state) snapshot given spec => String -> (Record props -> Record state -> Record state) -> ReactClassConstructor (Record props) (Record state) given -> ReactClass (Record props)Like component, but takes a getDerivedStateFromProps handler.
#pureComponent Source
pureComponent :: forall props state snapshot given spec. ReactPureComponentSpec (Record props) (Record state) snapshot given spec => String -> ReactClassConstructor (Record props) (Record state) given -> ReactClass (Record props)Creates a ReactClass inherited from React.PureComponent.
#pureComponentWithDerivedState Source
pureComponentWithDerivedState :: forall props state snapshot given spec. ReactPureComponentSpec (Record props) (Record state) snapshot given spec => String -> (Record props -> Record state -> Record state) -> ReactClassConstructor (Record props) (Record state) given -> ReactClass (Record props)Like pureComponent, but takes a getDerivedStateFromProps handler.
#statelessComponent Source
statelessComponent :: forall props. (Record props -> ReactElement) -> ReactClass (Record props)#ReactClass Source
data ReactClass t0React class for components.
#modifyState Source
modifyState :: forall props state. ReactThis props state -> (state -> state) -> Effect UnitUpdate component state given a modification function.
#forceUpdate Source
forceUpdate :: forall props state. ReactThis props state -> Effect UnitForce render of a react component.
#ReactPropFields Source
class ReactPropFields :: Row Type -> Row Type -> Constraintclass ReactPropFields (required :: Row Type) (given :: Row Type)
Instances
(Union given optional (ReservedReactPropFields required), Union optional leftover (ReservedReactPropFields ())) => ReactPropFields required given
#ReservedReactPropFields Source
type ReservedReactPropFields :: Row Type -> Row Typetype ReservedReactPropFields r = (key :: String, ref :: RefHandler ReactInstance | r)
#createElement Source
createElement :: forall required given. ReactPropFields required given => ReactClass { children :: Children | required } -> Record given -> Array ReactElement -> ReactElementCreate an element from a React class spreading the children array. Used when the children are known up front.
#unsafeCreateElement Source
unsafeCreateElement :: forall props. ReactClass { children :: Children | props } -> Record props -> Array ReactElement -> ReactElementAn unsafe version of createElement which does not enforce the reserved
properties "key" and "ref".
#createElementDynamic Source
createElementDynamic :: forall required given. ReactPropFields required given => ReactClass { children :: Children | required } -> Record given -> Array ReactElement -> ReactElementCreate an element from a React class passing the children array. Used for a dynamic array of children.
#unsafeCreateElementDynamic Source
unsafeCreateElementDynamic :: forall props. ReactClass { children :: Children | props } -> Record props -> Array ReactElement -> ReactElementAn unsafe version of createElementDynamic which does not enforce the reserved
properties "key" and "ref".
#createLeafElement Source
createLeafElement :: forall required given. ReactPropFields required given => ReactClass (Record required) -> Record given -> ReactElementCreate an element from a React class that does not require children. Additionally it can be used
when the children are represented /only/ through the children prop - for instance, a ContextConsumer
would be turned into a ReactElement with createLeafElement someContext.consumer { children: \x -> ... }.
#unsafeCreateLeafElement Source
unsafeCreateLeafElement :: forall props. ReactClass props -> props -> ReactElementAn unsafe version of createLeafElement which does not enforce the reserved
properties "key" and "ref".
#createElementTagName Source
createElementTagName :: forall props. TagName -> props -> Array ReactElement -> ReactElementCreate an element from a tag name spreading the children array. Used when the children are known up front.
#createElementTagNameDynamic Source
createElementTagNameDynamic :: forall props. TagName -> props -> Array ReactElement -> ReactElementCreate an element from a tag name passing the children array. Used for a dynamic array of children.
#Children Source
#childrenToArray Source
childrenToArray :: Children -> Array ReactElementInternal conversion function from children elements to an array of React elements
#childrenCount Source
childrenCount :: Children -> IntReturns the number of children.
#IsReactElement Source
#fragment Source
fragment :: ReactClass { children :: Children }#fragmentWithKey Source
fragmentWithKey :: String -> Array ReactElement -> ReactElementCreates a keyed fragment.
#Context Source
type Context a = { consumer :: ContextConsumer a, provider :: ContextProvider a }#ContextProvider Source
type ContextProvider a = ReactClass { children :: Children, value :: a }#ContextConsumer Source
type ContextConsumer a = ReactClass { children :: a -> ReactElement }#createContext Source
createContext :: forall a. a -> Context aCreate a new context provider/consumer pair given a default value.