purescript-concur / purescript-concur-react

Concur UI Framework for Purescript
https://purescript-concur.github.io/purescript-concur-react
MIT License
271 stars 17 forks source link

preventDefault #65

Open bilus opened 1 year ago

bilus commented 1 year ago

It would be useful to have this added to the library (great job BTW):

preventDefault :: P.ReactProps SyntheticInputEvent -> P.ReactProps SyntheticInputEvent
preventDefault = CP.handleProp $ liftEffect <<< SyntheticEvent.preventDefault

Usage example:

D.form [ SearchFormSubmitted <$ (preventDefault P.onSubmit) ]
  [ 
    -- Fields go here.
    SearchFormSubmitted <$ D.button [ P.onClick ] [ D.text "Search" ]
  ]

It's fantastic it wasn't there because I had no other choice but to understand what's under the hood but I think it's an useful addition. That plus an example of using handleProp. Just saying. :)

BTW. I had assumed Prop is a Monad; that threw me off a bit.

Thank you so much; I really enjoy using Concur!