reactpy
reactpy copied to clipboard
report better error for attrs that cannot be serialized
Issues
closes: #930
Summary
In reactpy.core.vdom.vdom check if attributes are JSON serializable when in debug mode.
Also misc changes to config options to make this easier in particular ability to specify options as parents.
Checklist
- [ ] Tests have been included for all bug fixes or added functionality.
- [ ] The
changelog.rsthas been updated with any significant changes.
We might also want to validate event handlers too. Need to ensure they're either coroutines or callable.
We might also want to validate event handlers too.
Event handlers are already extracted from attributes based on whether they are callable or not.
We might also want to validate event handlers too.
Event handlers are already extracted from attributes based on whether they are callable or not.
I currently don't see any warnings if I put in a string as an event handler.
from reactpy import component, html, run
@component
def test():
return html.div({"on_click": "do nothing"}, "Hello World")
run(test)
Also I don't see how this PR resolves #437
I currently don't see any warnings if I put in a string as an event handler.
This is strictly about ensuring that attributes are JSON serializable. Know what values are allowed for each attribute on each HTML element would need to be done in a follow-up PR.
Also I don't see how this PR resolves https://github.com/reactive-python/reactpy/issues/437
In debug mode, users will get an error if they attempt to pass non-JSON-serializable props to a JS components. They'd get that error without debug mode too, but in debug mode you get a more helpful one.