-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
component.get_hooks: inject hook code into react component functions #810
Conversation
The new Component `_get_hooks` and `get_hooks` methods may be overridden by subclasses to return javascript code to be compiled into the react component function after all of the state/event handling logic and before returning the rendered JSX Element. This allows components to use react hooks and extend or override pynecone state handling logic.
Awesome thanks for adding this! It looks good, I'll play around with it a bit and leave a review |
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
I have updated the @masenf example to make it work with current pynecone version (0.1.34).
It was just moving from Without that replace, the JS code generated was:
I just removed the |
docs coming soon for a less hacky way to accomplish this in reflex: reflex-dev/reflex-web#121 |
What I'm truly interested in is to wrap hooks to get oauth data (#395) |
The new Component
_get_hooks
andget_hooks
methods may be overridden by subclasses to return javascript code to be compiled into the react component function after all of the state/event handling logic and before returning the rendered JSX Element.This allows components to use react hooks and extend or override pynecone state handling logic.
All Submissions:
Type of change
New Feature Submission:
Changes To Core Features:
Example
Here is a
PersistentToken
component, which defines auseEffect
hook to get/set a more persistent identifier in localStorage:Which ends up generating code like this
Thanks for your consideration.