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

[reflex-web tweaks] Do not memoize children of InputGroup #2230

Merged
merged 4 commits into from
Nov 30, 2023

Conversation

masenf
Copy link
Collaborator

@masenf masenf commented Nov 29, 2023

The Chakra InputGroup component depends on its children being specific types of components, so a memoized Input_* is not "seen" as the input component.

The Chakra InputGroup component depends on its children being specific types of
components, so a memoized Input_* is not "seen" as the input component.
from reflex.components.layout.foreach import Foreach

# Foreach must be memoized as a single component to retain index Var context.
if not isinstance(component, Foreach):
if not isinstance(component, (Foreach, InputGroup)):
Copy link
Contributor

Choose a reason for hiding this comment

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

We should update the comment here too. Do we need to add any other components to this tuple?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, maybe the ButtonGroup. I'll poke around

@Alek99 Alek99 self-requested a review November 29, 2023 22:47
To help handle memoization exceptions and special cases as they are discovered,
use a field on Component which controls aspecs of the auto-memoization process.

For now, only the "recursive" boolean is understood.

There is certain to be future categories of exceptions to memoization that will
be discovered, so instead of plumbing additional fields through, the
MemoizationMode can be extended with defaults and used to handle these special
cases in the components that need them, rather than centrally in the Component
or StatefulComponent logic.

Replace special case recursive logic for Foreach and InputGroup components with
this new mechanism.
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.

Nice, I like this approach

@picklelo picklelo merged commit a2d5bbc into main Nov 30, 2023
45 checks passed
@masenf masenf deleted the masenf/reflex-web-tweaks branch November 30, 2023 17:48
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