-
Notifications
You must be signed in to change notification settings - Fork 1
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
Remove reliance on CamelCase component names #9
Remove reliance on CamelCase component names #9
Conversation
Accidentally PR'd the archived repo. Moving to idom-team/flake8-idom#3 |
I unarchived this a while back. Haven't had time to switch to flake8-idom. |
A note on this this - one reason using the CamelCase for function component definitions makes sense is that the behavior is much more like that of a class. If for example, we named these with snake case one might expect the following to be true: @component
def my_component():
print("It ran!")
return idom.html.div()
assert my_component() == idom.html.div() However, in reality: assert isinstance(my_component(), Component) We also do not see the print statement. To get the initially expected result we must do manually, what the layout automatically would otherwise: instance = my_component()
assert instance.render() == idom.html.div() STDOUT:
The take away here being that the naming of function components with CamelCase is more than just stylistic. It is an attempt to indicate a behavioral difference between functions that are/aren't components - functions named with CamelCase behave much more like a class (i.e. it's an object constructor). |
To end users, that's irrelevant. Functions def = Regardless of what they mutate into due to the decorator, I believe PEP8 should be followed. Plus we can't expect most users to use the |
You'll need to update the test cases in this file to use an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM besides this. Will merge and release next week.
closed in favor of #14 |
is_component_def
now checks if a function is decorated with@idom.component
to determine whether something is a component.This implementation also works if directly using
@component
as a decorator.Also, all hook names are now explicitly checked for rather than assuming everything
use_*
is a hook.