Module
React.Basic.Events
- Package
- purescript-react-basic
- Repository
- lumihq/purescript-react-basic
#EventHandler Source
type EventHandler = EffectFn1 SyntheticEvent Unit
An event handler, which receives a SyntheticEvent
and performs some
effects in return.
#SyntheticEvent Source
data SyntheticEvent :: Type
Event data that we receive from React.
#EventFn Source
newtype EventFn a b
Encapsulates a safe event operation. EventFn
s can be composed
to perform multiple operations.
For example:
input { onChange: handler (preventDefault >>> targetValue)
\value -> setState \_ -> { value }
}
Instances
#unsafeEventFn Source
unsafeEventFn :: forall b a. (a -> b) -> EventFn a b
Unsafely create an EventFn
. This function should be avoided as it can allow
a SyntheticEvent
to escape its scope. Accessing a React event's properties is only
valid in a synchronous event callback.
Instead, use the helper functions specific to your platform, such as React.Basic.DOM.Events
.
#handler Source
handler :: forall a. EventFn SyntheticEvent a -> (a -> Effect Unit) -> EventHandler
Create an EventHandler
, given an EventFn
and a callback.
For example:
input { onChange: handler targetValue
\value -> setState \_ -> { value }
}
#handler_ Source
handler_ :: Effect Unit -> EventHandler
Create an EventHandler
which discards the SyntheticEvent
.
For example:
input { onChange: handler_ (setState \_ -> { value })
}
#merge Source
merge :: forall r fns_list fns a. RowToList fns fns_list => Merge fns_list fns a r => Record fns -> EventFn a (Record r)
Merge multiple EventFn
operations and collect their results.
For example:
input { onChange: handler (merge { targetValue, timeStamp })
\{ targetValue, timeStamp } -> setState \_ -> { ... }
}
- 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