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

The nested component inherits the parent context data even without explicit parameter passing. #579

Open
mahmoud-alawad opened this issue Nov 21, 2024 · 2 comments

Comments

@mahmoud-alawad
Copy link

Describe the bug
Nested components unexpectedly have access to the parent component's context data, even when no parameters or props are explicitly passed to them. This causes unexpected behavior and potential data leakage, leading to unintended side effects in the application.

To Reproduce
Steps to reproduce the behavior:

  1. Create a parent component with some context-based data or state.
  2. Add a nested component inside the parent component.
  3. Without passing any props or parameters, try to access the parent context from the nested component.
  4. Observe that the nested component can access the parent context data.

Expected behavior
The nested component should not have access to the parent context data unless explicitly passed via props or another intentional mechanism.

Screenshots
2024-11-21_14-11

To prevent the issue in the example, the element property must be explicitly passed across all project files, ensuring consistent behavior and avoiding unintended context sharing. as down here

2024-11-21_14-12

The context must be reset at the root level each time the component is rendered to ensure a clean state and prevent unintended data persistence across renders.

@timohubois
Copy link
Contributor

@mahmoud-alawad Nice catch, and many thanks for reporting this!

It would be great if you could create a pull request (PR) with a suggestion on how this issue can be resolved. Would that be an option for you?

@mahmoud-alawad
Copy link
Author

@timohubois
May have a look on this pr #580

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

No branches or pull requests

2 participants