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 ReactComponent :: Type
A mounted react component
#EventHandler Source
data EventHandler :: Type -> Type
An event handler. The type argument represents the type of the event.
#Disallowed Source
type Disallowed = () :: Row Effect
An access synonym which indicates that neither read nor write access are allowed.
#ReactState Source
data ReactState :: Row Effect -> Effect
This effect indicates that a computation may read or write the component state.
The first type argument is a row of access types (Read
, Write
).
#ReactProps Source
data ReactProps :: Effect
This effect indicates that a computation may read the component props.
#MouseEvent Source
type MouseEvent = { pageX :: Number, pageY :: Number }
The type of mouse events.
#EventHandlerContext Source
type EventHandlerContext eff props state result = Eff (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadWrite | eff) result
A function which handles events.
#Render Source
type Render props state render eff = ReactThis props state -> Eff (props :: ReactProps, refs :: ReactRefs Disallowed, state :: ReactState ReadOnly | eff) render
A render function.
#GetInitialState Source
type GetInitialState props state eff = ReactThis props state -> Eff (props :: ReactProps, refs :: ReactRefs Disallowed, state :: ReactState Disallowed | eff) state
A get initial state function.
#ComponentWillMount Source
type ComponentWillMount props state eff = ReactThis props state -> Eff (props :: ReactProps, refs :: ReactRefs Disallowed, state :: ReactState ReadWrite | eff) Unit
A component will mount function.
#ComponentDidMount Source
type ComponentDidMount props state eff = ReactThis props state -> Eff (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadWrite | eff) Unit
A component did mount function.
#ComponentDidCatch Source
type ComponentDidCatch props state eff = ReactThis props state -> Error -> { componentStack :: String } -> Eff (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadWrite | eff) Unit
#ComponentWillReceiveProps Source
type ComponentWillReceiveProps props state eff = ReactThis props state -> props -> Eff (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadWrite | eff) Unit
A component will receive props function.
#ShouldComponentUpdate Source
type ShouldComponentUpdate props state eff = ReactThis props state -> props -> state -> Eff (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadWrite | eff) Boolean
A should component update function.
#ComponentWillUpdate Source
type ComponentWillUpdate props state eff = ReactThis props state -> props -> state -> Eff (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadWrite | eff) Unit
A component will update function.
#ComponentDidUpdate Source
type ComponentDidUpdate props state eff = ReactThis props state -> props -> state -> Eff (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadOnly | eff) Unit
A component did update function.
#ComponentWillUnmount Source
type ComponentWillUnmount props state eff = ReactThis props state -> Eff (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadOnly | eff) Unit
A component will unmount function.
#ReactSpec Source
type ReactSpec props state render eff = { componentDidCatch :: Maybe (ComponentDidCatch props state eff), componentDidMount :: ComponentDidMount props state eff, componentDidUpdate :: ComponentDidUpdate props state eff, componentWillMount :: ComponentWillMount props state eff, componentWillReceiveProps :: ComponentWillReceiveProps props state eff, componentWillUnmount :: ComponentWillUnmount props state eff, componentWillUpdate :: ComponentWillUpdate props state eff, displayName :: String, getInitialState :: GetInitialState props state eff, render :: Render props state render eff, shouldComponentUpdate :: ShouldComponentUpdate props state eff }
A specification of a component.
#spec Source
spec :: forall eff render state props. ReactRender render => state -> Render props state render eff -> ReactSpec props state render eff
Create a component specification with a provided state.
#spec' Source
spec' :: forall eff render state props. ReactRender render => GetInitialState props state eff -> Render props state render eff -> ReactSpec props state render eff
Create a component specification with a get initial state function.
#ReactClass Source
data ReactClass :: Type -> Type
React class for components.
#getProps Source
getProps :: forall eff state props. ReactThis props state -> Eff (props :: ReactProps | eff) props
Read the component props.
#getChildren Source
getChildren :: forall eff state props. ReactThis props state -> Eff (props :: ReactProps | eff) (Array ReactElement)
Read the component children property.
#writeState Source
writeState :: forall eff access state props. ReactThis props state -> state -> Eff (state :: ReactState (write :: Write | access) | eff) state
Write the component state.
#writeStateWithCallback Source
writeStateWithCallback :: forall eff access state props. ReactThis props state -> state -> Eff (state :: ReactState (write :: Write | access) | eff) Unit -> Eff (state :: ReactState (write :: Write | access) | eff) state
Write the component state with a callback.
#readState Source
readState :: forall eff access state props. ReactThis props state -> Eff (state :: ReactState (read :: Read | access) | eff) state
Read the component state.
#transformState Source
transformState :: forall eff state props. ReactThis props state -> (state -> state) -> Eff (state :: ReactState ReadWrite | eff) Unit
Transform the component state by applying a function.
#createClass Source
createClass :: forall eff render state props. ReactSpec props state render eff -> ReactClass props
#createClassStateless Source
createClassStateless :: forall render props. ReactRender render => (props -> render) -> ReactClass props
Create a stateless React class. When using a non anonymous function the displayName will be the capitalized name of the function, e.g.
helloWorld = createClassStatelesss helloWorldCls
where
helloWorldCls props = ...
Then the displayName
will be set up to HelloWorldCls
#createClassStateless' Source
createClassStateless' :: forall render props. ReactRender render => (props -> Array ReactElement -> render) -> ReactClass props
Create a stateless React class with children access.
#forceUpdate Source
forceUpdate :: forall state props eff. ReactThis props state -> Eff eff Unit
Force render of a react component.
#handle Source
handle :: forall result state props ev eff. (ev -> EventHandlerContext eff props state result) -> EventHandler ev
Create an event handler.
#createElement Source
createElement :: forall props. ReactClass props -> props -> Array ReactElement -> ReactElement
Create an element from a React class spreading the children array. Used when the children are known up front.
#createElementDynamic Source
createElementDynamic :: forall props. ReactClass props -> props -> Array ReactElement -> ReactElement
Create an element from a React class passing the children array. Used for a dynamic array of children.
#createElementTagName Source
createElementTagName :: forall props. TagName -> props -> Array ReactElement -> ReactElement
Create 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 -> ReactElement
Create an element from a tag name passing the children array. Used for a dynamic array of children.
#createFactory Source
createFactory :: forall props. ReactClass props -> props -> ReactElement
Create a factory from a React class.
#childrenToArray Source
childrenToArray :: Children -> Array ReactElement
Internal conversion function from children elements to an array of React elements