Module
React.Basic.Compat
- Package
- purescript-react-basic
- Repository
- lumihq/purescript-react-basic
This module is deprecated and may be removed in the next major version.
#Component Source
type Component = ReactComponent
#component Source
component :: forall state props. { displayName :: String, initialState :: Record state, receiveProps :: Self (Record props) (Record state) -> Effect Unit, render :: Self (Record props) (Record state) -> JSX } -> ReactComponent (Record props)
Supports a common subset of the v2 API to ease the upgrade process
Re-exports from React.Basic
#Self Source
type Self props state = { instance_ :: ReactComponentInstance props state, props :: props, setState :: (state -> state) -> Effect Unit, setStateThen :: (state -> state) -> Effect Unit -> Effect Unit, state :: state }
Self
represents the component instance at a particular point in time.
props
- A snapshot of
props
taken when thisSelf
was created.
- A snapshot of
state
- A snapshot of
state
taken when thisSelf
was created.
- A snapshot of
setState
- Update the component's state using the given function.
setStateThen
- Update the component's state using the given function. The given effects are performed after any resulting rerenders are completed. Be careful to avoid using stale props or state in the effect callback. Use
readProps
orreadState
to aquire the latest values.
- Update the component's state using the given function. The given effects are performed after any resulting rerenders are completed. Be careful to avoid using stale props or state in the effect callback. Use
instance_
- Unsafe escape hatch to the underlying component instance (
this
in the JavaScript React paradigm). Avoid as much as possible, but it's still frequently better than rewriting an entire component in JavaScript.
- Unsafe escape hatch to the underlying component instance (
See also: ComponentSpec
, send
, capture
, readProps
, readState
#JSX Source
data JSX :: Type
Represents rendered React VDOM (the result of calling React.createElement
in JavaScript).
JSX
is a Monoid
:
append
- Merge two
JSX
nodes usingReact.Fragment
.
- Merge two
mempty
- The
empty
node; renders nothing.
- The
Hint: Many useful utility functions already exist for Monoids. For example,
guard
can be used to conditionally render a subtree of components.
Instances
#elementKeyed Source
elementKeyed :: forall props. ReactComponent (Record props) -> { key :: String | props } -> JSX
Create a JSX
node from a ReactComponent
, by providing the props and a key.
See also: ReactComponent
, element
, React's documentation regarding the special key
prop
- Modules
- React.
Basic - React.
Basic. Compat - React.
Basic. Components. Async - React.
Basic. DOM - React.
Basic. DOM. Components. GlobalEvents - React.
Basic. DOM. Components. LogLifecycles - React.
Basic. DOM. Components. Ref - React.
Basic. DOM. Events - React.
Basic. DOM. Generated - React.
Basic. DOM. Internal - React.
Basic. DOM. SVG - React.
Basic. Events