Module

React.Ix

Package
purescript-react-ix
Repository
coot/purescript-react-ix

#ReactThisIx Source

newtype ReactThisIx p s (r :: Row Type)

Constructors

#getProp Source

getProp :: forall eff s p a l r' r. IsSymbol l => RowCons l a r' r => SProxy l -> ReactThisIx p s r -> Eff eff a

Safe way of reading a property. Note that if you set a callback within a life-cycle method where the property is defined, and it will be called after the component is unmounted this might return undefined (if you removed that property in componentWillUnmount). The usual workaround that is to set isMounted property in componentWillMount and then reset it on componentWillUnmount and check it before reading in async callbacks.

#getPropIx Source

getPropIx :: forall eff s p a l r' r. IsSymbol l => RowCons l a r' r => SProxy l -> ReactThisIx p s r -> EffR eff (RProxy r) (RProxy r) a

#setProp Source

setProp :: forall eff s p b a l r r2 r1. IsSymbol l => RowCons l a r r1 => RowCons l b r r2 => SProxy l -> b -> ReactThisIx p s r1 -> Eff eff (ReactThisIx p s r2)

#setPropIx Source

setPropIx :: forall eff s p b a l r r2 r1. IsSymbol l => RowCons l a r r1 => RowCons l b r r2 => SProxy l -> b -> ReactThisIx p s r1 -> EffR eff (RProxy r1) (RProxy r2) (ReactThisIx p s r2)

#modifyProp Source

modifyProp :: forall eff s p b a l r r2 r1. IsSymbol l => RowCons l a r r1 => RowCons l b r r2 => SProxy l -> (a -> b) -> ReactThisIx p s r1 -> Eff eff (ReactThisIx p s r2)

#modifyPropIx Source

modifyPropIx :: forall eff s p b a l r r2 r1. IsSymbol l => RowCons l a r r1 => RowCons l b r r2 => SProxy l -> (a -> b) -> ReactThisIx p s r1 -> EffR eff (RProxy r1) (RProxy r2) (ReactThisIx p s r2)

#insertPropIx Source

insertPropIx :: forall eff s p a l r2 r1. IsSymbol l => RowLacks l r1 => RowCons l a r1 r2 => SProxy l -> a -> ReactThisIx p s r1 -> EffR eff (RProxy r1) (RProxy r2) (ReactThisIx p s r2)

#nullifyPropIx Source

nullifyPropIx :: forall eff s p a l r2 r1. IsSymbol l => RowLacks l r1 => RowCons l a r1 r2 => SProxy l -> ReactThisIx p s r2 -> EffR eff (RProxy r2) (RProxy r1) (ReactThisIx p s r1)

Set a property as null and remove it from EffR. Set to null rather than delete just to be consistent with react, which calls ref callbacks with null when component is unmounted.

#RenderIx Source

type RenderIx props state ri ro eff = ReactThisIx props state ri -> EffR (props :: ReactProps, refs :: ReactRefs Disallowed, state :: ReactState ReadOnly | eff) (RProxy ri) (RProxy ro) ReactElement

A render function.

#GetInitialStateIx Source

type GetInitialStateIx props state r eff = ReactThisIx props state r -> EffR (props :: ReactProps, refs :: ReactRefs Disallowed, state :: ReactState Disallowed | eff) (RProxy r) (RProxy r) state

A get initial state function.

#ComponentWillMountIx Source

type ComponentWillMountIx props state r eff = ReactThisIx props state () -> EffR (props :: ReactProps, refs :: ReactRefs Disallowed, state :: ReactState ReadWrite | eff) (RProxy ()) (RProxy r) (ReactThisIx props state r)

A component will mount function.

#ComponentDidMountIx Source

type ComponentDidMountIx props state r eff = ReactThisIx props state r -> EffR (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadWrite | eff) (RProxy r) (RProxy r) Unit

A component did mount function.

#ComponentWillReceivePropsIx Source

type ComponentWillReceivePropsIx props state r eff = ReactThisIx props state r -> props -> EffR (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadWrite | eff) (RProxy r) (RProxy r) Unit

A component will receive props function.

#ShouldComponentUpdateIx Source

type ShouldComponentUpdateIx props state (r :: Row Type) (eff :: Row Effect) = ReactThisIx props state r -> props -> state -> EffR (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadWrite | eff) (RProxy r) (RProxy r) Boolean

A should component update function.

#ComponentWillUpdateIx Source

type ComponentWillUpdateIx props state r eff = ReactThisIx props state r -> props -> state -> EffR (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadWrite | eff) (RProxy r) (RProxy r) Unit

A component will update function.

#ComponentDidUpdateIx Source

type ComponentDidUpdateIx props state r eff = ReactThisIx props state r -> props -> state -> EffR (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadOnly | eff) (RProxy r) (RProxy r) Unit

A component did update function.

#ComponentWillUnmountIx Source

type ComponentWillUnmountIx props state r ro eff = ReactThisIx props state r -> EffR (props :: ReactProps, refs :: ReactRefs ReadOnly, state :: ReactState ReadOnly | eff) (RProxy r) (RProxy ro) (ReactThisIx props state ro)

A component will unmount function.

#ReactSpecIx Source

type ReactSpecIx p s (ri :: Row Type) (rr :: Row Type) (ro :: Row Type) (eff :: Row Effect) = forall ro' ri'. Union ri ri' rr => Union ro ro' rr => { componentDidMount :: ComponentDidMountIx p s rr eff, componentDidUpdate :: ComponentDidUpdateIx p s rr eff, componentWillMount :: ComponentWillMountIx p s ri eff, componentWillReceiveProps :: ComponentWillReceivePropsIx p s rr eff, componentWillUnmount :: ComponentWillUnmountIx p s rr ro eff, componentWillUpdate :: ComponentWillUpdateIx p s rr eff, displayName :: String, getInitialState :: GetInitialStateIx p s ri eff, render :: RenderIx p s ri rr eff, shouldComponentUpdate :: ShouldComponentUpdateIx p s rr eff }

Track added properties on the type level.

  • ri row describes added properties in ComponentWillMountIx (callbacks)
  • rr row describes added properties within render method (refs)
  • ro row is the state of ReactThis after componetnWillUnmount.

Likely you want to use

ReactSpecIx p s ri rr () eff

This will ensure that you don't leak memory, by keeping a reference.

#specIx' Source

specIx' :: forall eff ro' ro rr ri' ri s p. Union ro ro' rr => Union ri ri' rr => GetInitialStateIx p s ri eff -> ComponentWillMountIx p s ri eff -> ComponentWillUnmountIx p s rr ro eff -> RenderIx p s ri rr eff -> ReactSpecIx p s ri rr ro eff

#specIx Source

specIx :: forall eff s p. s -> RenderIx p s () () eff -> ReactSpecIx p s () () () eff

#toReactSpec Source

toReactSpec :: forall eff ro' ro rr ri' ri s p. Union ri ri' rr => Union ro ro' rr => ReactSpecIx p s ri rr ro eff -> ReactSpec p s eff

#fromReactSpec Source

fromReactSpec :: forall eff s p. ReactSpec p s eff -> ReactSpecIx p s () () () eff

#underReactSpecIx Source

underReactSpecIx :: forall eff2 eff1 o' o r i' i s2 p2 s1 p1. Union i i' r => Union o o' r => (ReactSpecIx p1 s1 () () () eff1 -> ReactSpecIx p2 s2 i r o eff2) -> ReactSpec p1 s1 eff1 -> ReactSpec p2 s2 eff2

Think of ReactSpecIx as a newtype wrapper around ReactSpecIx, thus under.

#createClassIx Source

createClassIx :: forall eff ro' ro rr ri' ri s p. Union ri ri' rr => Union ro ro' rr => ReactSpecIx p s ri rr ro eff -> ReactClass p

#refFn Source

refFn :: forall ro ri eff element. (element -> EffR eff (RProxy ri) (RProxy ro) Unit) -> EffR eff (RProxy ri) (RProxy ro) Props