-
-
Notifications
You must be signed in to change notification settings - Fork 324
Use props dict
on components, rather than kwargs.
#993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
More precisely the interface should conform to this protocol. |
We can potentially retain type hints using this PEP https://peps.python.org/pep-0692/ |
I spent more thought on this issue while rewriting the docs. @rmorshea We need to decide what we will do with the user's component function defs. See my updates above. |
Note: we'll have to figure out how this will play work if the component function is a method. |
I did some prototyping, and learned it's currently not possible to use Given that components are functions, it feels natural for users to call them via the standard "python function interface" (AKA arguments within parenthesis) Additionally, changing the Unless the Python type hinting space makes some major changes, I think we're forced to continue down the road we've already paved. I've already raised the issue that the Python type hinting system has no way to "mutate" kwargs, so hopefully that gains some interest/traction. |
A draft of the template strings PEP is currently in review so optimizing the interface may not be necessary anyways if that lands. |
Agreed, I recently made that same conclusion while talking about the |
Current Situation
There's been a lot of growing pains in the fact that components have a significantly different interface than
reactpy.html
elements.Developing certain parts of
reactpy
core and/orreactpy
related utilities has been significantly more difficult due to this interface mismatch.Proposed Actions
The new component interface should match the VDOM interface, and will look like this:
As a part of this change, we should rename
VdomAttributes
toProps
.Do we retain args/kwargs?
We can handle
@component
function definitions a few ways. Some of these ways feel more similar to ReactJS, but have problems with Python type hints.props: dict
as their first parameterI'm personally leaning towards option 1.
The text was updated successfully, but these errors were encountered: