Skip to content
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

Make @rx.memo work with state vars passed as props #2810

Merged
merged 3 commits into from
Mar 13, 2024

Conversation

masenf
Copy link
Collaborator

@masenf masenf commented Mar 7, 2024

Seems like this was a regression from the StatefulComponent refactor, because trying to pass a state Var to a CustomComponent gave undefined, likely due to _get_vars not accounting for self.props in CustomComponents.

With this change, it works.

Integration test added to test_var_operations.py

masenf added 3 commits March 7, 2024 15:17
Seems like this was a regression from the StatefulComponent refactor, because
trying to pass a state Var to a CustomComponent gave undefined, likely due to
`_get_vars` not accounting for `self.props` in CustomComponents.

With this change, it works.

Integration test added to `test_var_operations.py`
Avoid calling `.json()` on all Base types because the Var serializer already
does that, but this way, more specific types (like Component) can be serialized
differently.

When the type is Component, attach a VarData with the imports and hooks to when
the Var is rendered, it also carries the correct imports/hooks and does not
throw frontend errors.
Copy link
Contributor

@picklelo picklelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@masenf masenf merged commit 036afa9 into main Mar 13, 2024
45 checks passed
@masenf masenf deleted the masenf/custom-component-state branch March 13, 2024 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants