-
-
Notifications
You must be signed in to change notification settings - Fork 324
Nested context does not update value if outer context should not render #846
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
I'm unable to reproduce - this test passes. Can you provide sample code I can use to test this? |
EDIT: Wrong issue. This comment can be ignored.
|
My suspicion here is that this logic is wrong. After reading a bit, context providers don't actually stop descendants that do not |
This fact, that presently in IDOM the descendants of a context (except those that |
We might want to develop memo components before removing the Also it's worth double checking that the one commenter on stackoverflow is telling the truth. |
In ReactJS, |
I think the issue I'm seeing might be Still trying to dig a bit deeper and confirm this. The issues seem fairly random though, sometimes calling |
I've committed an example of problematic nested contexts. It seems like calling Issue can be detected by creating several app store subcategories, and then clicking through them. Also, if you click on the "details" button on any card (triggers a re-render of the page), then all children within my sub-context go poof. This issue can be replicated by pulling down Archmonger/Conreq@f21ea6e |
set_state
are broken
Maybe there's an additional layer to consider with conditionally rendered components. I wasn't able to reproduce using this example from typing import Callable
from idom import component, hooks, html, run
from dataclasses import dataclass
from flask import Flask
@dataclass
class State:
value: int = 0
set_value: Callable = lambda x: None
@dataclass
class RootState:
doesnt_matter: int = 0
RootContext = hooks.create_context(RootState())
SubContext = hooks.create_context(State())
@component
def root():
return RootContext(child(), value=RootState(123))
@component
def child():
state, set_state = hooks.use_state(State(value=456))
state.set_value = set_state
print("`state.value` value should start as 456 change to 666 when clicked: ", state)
return SubContext(
str(state),
html.button(
{"onClick": lambda x: set_state(State(value=666))},
"Click Me",
),
value=state,
)
run(root) |
I think we can remove the |
set_state
are broken
There is somehow still some lingering issues with this fix. Do you have time this weekend for me to demo? |
Sure. Sat or mid-day Sun work |
Spoke too soon. It was an issue on my end. |
Current Situation
ReactJS appears to support nested context.
However, in IDOM situations like the following simply don't render...
Proposed Actions
Modify the
ContextProvider
to support nested contexts.The text was updated successfully, but these errors were encountered: