nwolverson / purescript-react-material-ui

purescript-react bindings for material-ui
MIT License
8 stars 3 forks source link

How to handle `onChange` event for input #3

Open martyall opened 7 years ago

martyall commented 7 years ago

in MaterialUI.Input the type of onChange is

onChange :: Option InputOption (UnknownType)

but it seems like you would want to use

onChange :: Option InputOption (EventHandlerOpt)

if this is intentional, can you please explain how I can convert the following piece of code using purescript-react to material ui?

addressInput :: ReactElement
addressInput = 
    D.input [ P._type "text"
            , P.placeholder "0xdeadbeef"
            , P.onChange \e -> dispatch (UpdateAddress (unsafeCoerce e).target.value)
            ] []
martyall commented 7 years ago

I see now that this module was auto-generated, which might make it more complicated...

nwolverson commented 7 years ago

Right now I think something like UnknownType (toForeign yourHandler). The constructor is exposed as an escape hatch so you can do anything (and shoot your foot), as I'm sure some more types won't be usefully translated.

Probably if the generator can't be improved there should be at least a way of overriding it without editing the generated code.