| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Hi @nojaf ! |
Sorry, something went wrong.
|
Feel free to push to this branch. |
Sorry, something went wrong.
|
Hi, I'm testing the PR. Is this the way to onChange on input or I'm missing something? let onChange = (event: ReactEvent.Form.t) => {
let input: WebAPI.DOMAPI.htmlInputElement =
event->ReactEvent.Form.target->WebAPI.Prelude.unsafeConversation
handleChange(input.value)
} |
Sorry, something went wrong.
|
Hey Freddy, Yeah, that is still a bit of a tricky one. The target can be multiple things (for example select) so we can't quite pick a useful type here. WebAPI.Prelude.unsafeConversation is also really an alias for Obj.magic, which is something we might also want to revisit at some point. One other thing that comes to mind here is to do an inline %raw instanceof check. But yeah, no ideal solution. |
Sorry, something went wrong.
|
The previous {..} wasn’t safe either, but to me it’s better now. I don’t see a better solution than providing a custom Event for each HTML element, so that currentTarget can be a DOMAPI.htmlInputElement / DOMAPI.htmlSelectElement / etc. instead of a generic DOMAPI.node. Typing the DOM API is hard. Something like react-strict-dom would probably be easier - but that’s off topic. I think the current WebAPI approach is fine as it is; it’s permissive. |
Sorry, something went wrong.
|
Maybe a helper to get the .value as string (option?) would go a long way. |
Sorry, something went wrong.
|
For forms & inputs, yes, but that doesn’t solve other types of events. On HTML*Element we already have asNode for type converting, so why not also have a fromNode on each element? (because adding all asHTML*Element on the Node module would be huge) |
Sorry, something went wrong.
|
Because fromNode would require a runtime check to be safe. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This is a sample PR to illustrate the usage of the new WebAPI.
Some types in ReactDOM and ReactEvent were changed to match the new bindings.
As only the new types are used (which will be quite stable), this might not be as radical a change.
(PS: not saying we should merge this PR anytime soon)