Module

React

Package
purescript-react
Repository
purescript-contrib/purescript-react

This module defines foreign types and functions which wrap React's functionality.

#TagName Source

type TagName = String

Name of a tag.

#ReactElement Source

data ReactElement :: Type

A virtual DOM node, or component.

#ReactComponent Source

data ReactComponent :: Type

A mounted react component

#ReactThis Source

data ReactThis :: Type -> Type -> Type

A reference to a component, essentially React's this.

#EventHandler Source

data EventHandler :: Type -> Type

An event handler. The type argument represents the type of the event.

#Read Source

data Read :: Effect

This phantom type indicates that read access to a resource is allowed.

#Write Source

data Write :: Effect

This phantom type indicates that write access to a resource is allowed.

#Disallowed Source

type Disallowed = () :: # Effect

An access synonym which indicates that neither read nor write access are allowed.

#ReadWrite Source

type ReadWrite = (read :: Read, write :: Write)

An access synonym which indicates that both read and write access are allowed.

#ReadOnly Source

type ReadOnly = (read :: Read)

An access synonym which indicates that reads are allowed but writes are not.

#ReactState Source

data ReactState :: # 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.

#ReactRefs Source

data ReactRefs :: # Effect -> Effect

This effect indicates that a computation may read the component refs.

The first type argument is a row of access types (Read, Write).

#Refs Source

data Refs :: Type

The type of refs objects.

#Event Source

data Event :: Type

The type of DOM events.

#MouseEvent Source

type MouseEvent = { pageX :: Number, pageY :: Number }

The type of mouse events.

#KeyboardEvent Source

type KeyboardEvent = { altKey :: Boolean, ctrlKey :: Boolean, charCode :: Int, key :: String, keyCode :: Int, locale :: String, location :: Int, metaKey :: Boolean, repeat :: Boolean, shiftKey :: Boolean, which :: Int }

The type of keyboard 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 eff = ReactThis props state -> Eff (props :: ReactProps, refs :: ReactRefs Disallowed, state :: ReactState ReadOnly | eff) ReactElement

A render function.

#GetInitialState Source

type GetInitialState props state eff = ReactThis props state -> Eff (props :: ReactProps, state :: ReactState Disallowed, refs :: ReactRefs Disallowed | eff) state

A get initial state function.

#ComponentWillMount Source

type ComponentWillMount props state eff = ReactThis props state -> Eff (props :: ReactProps, state :: ReactState ReadWrite, refs :: ReactRefs Disallowed | eff) Unit

A component will mount function.

#ComponentDidMount Source

type ComponentDidMount props state eff = ReactThis props state -> Eff (props :: ReactProps, state :: ReactState ReadWrite, refs :: ReactRefs ReadOnly | eff) Unit

A component did mount function.

#ComponentWillReceiveProps Source

type ComponentWillReceiveProps props state eff = ReactThis props state -> props -> Eff (props :: ReactProps, state :: ReactState ReadWrite, refs :: ReactRefs ReadOnly | eff) Unit

A component will receive props function.

#ShouldComponentUpdate Source

type ShouldComponentUpdate props state eff = ReactThis props state -> props -> state -> Eff (props :: ReactProps, state :: ReactState ReadWrite, refs :: ReactRefs ReadOnly | eff) Boolean

A should component update function.

#ComponentWillUpdate Source

type ComponentWillUpdate props state eff = ReactThis props state -> props -> state -> Eff (props :: ReactProps, state :: ReactState ReadWrite, refs :: ReactRefs ReadOnly | eff) Unit

A component will update function.

#ComponentDidUpdate Source

type ComponentDidUpdate props state eff = ReactThis props state -> props -> state -> Eff (props :: ReactProps, state :: ReactState ReadOnly, refs :: ReactRefs ReadOnly | eff) Unit

A component did update function.

#ComponentWillUnmount Source

type ComponentWillUnmount props state eff = ReactThis props state -> Eff (props :: ReactProps, state :: ReactState ReadOnly, refs :: ReactRefs ReadOnly | eff) Unit

A component will unmount function.

#ReactSpec Source

type ReactSpec props state eff = { render :: Render props state eff, displayName :: String, getInitialState :: GetInitialState props state eff, componentWillMount :: ComponentWillMount props state eff, componentDidMount :: ComponentDidMount props state eff, componentWillReceiveProps :: ComponentWillReceiveProps props state eff, shouldComponentUpdate :: ShouldComponentUpdate props state eff, componentWillUpdate :: ComponentWillUpdate props state eff, componentDidUpdate :: ComponentDidUpdate props state eff, componentWillUnmount :: ComponentWillUnmount props state eff }

A specification of a component.

#spec Source

spec :: forall props state eff. state -> Render props state eff -> ReactSpec props state eff

Create a component specification with a provided state.

#spec' Source

spec' :: forall props state eff. GetInitialState props state eff -> Render props state eff -> ReactSpec props state 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 props state eff. ReactThis props state -> Eff (props :: ReactProps | eff) props

Read the component props.

#getRefs Source

getRefs :: forall props state access eff. ReactThis props state -> Eff (refs :: ReactRefs (read :: Read | access) | eff) Refs

Read the component refs.

#getChildren Source

getChildren :: forall props state eff. ReactThis props state -> Eff (props :: ReactProps | eff) (Array ReactElement)

Read the component children property.

#writeState Source

writeState :: forall props state access eff. ReactThis props state -> state -> Eff (state :: ReactState (write :: Write | access) | eff) state

Write the component state.

#writeStateWithCallback Source

writeStateWithCallback :: forall props state access eff. 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 props state access eff. ReactThis props state -> Eff (state :: ReactState (read :: Read | access) | eff) state

Read the component state.

#transformState Source

transformState :: forall props state eff. ReactThis props state -> (state -> state) -> Eff (state :: ReactState ReadWrite | eff) Unit

Transform the component state by applying a function.

#createClass Source

createClass :: forall props state eff. ReactSpec props state eff -> ReactClass props

Create a React class from a specification.

#createClassStateless Source

createClassStateless :: forall props. (props -> ReactElement) -> ReactClass props

Create a stateless React class.

#createClassStateless' Source

createClassStateless' :: forall props. (props -> Array ReactElement -> ReactElement) -> ReactClass props

Create a stateless React class with children access.

#handle Source

handle :: forall eff ev props state result. (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.

#preventDefault Source

preventDefault :: forall eff a. Event -> Eff eff a

#stopPropagation Source

stopPropagation :: forall eff a. Event -> Eff eff a