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

Proposal: Use React context instead of prop drilling for accessing shared state #84

Open
tortmayr opened this issue Feb 27, 2024 · 0 comments
Assignees

Comments

@tortmayr
Copy link
Contributor

tortmayr commented Feb 27, 2024

Description

As mentioned in this discussion by @colin-grant-work we currently need a lot of props drilling to pass the relevant data to our components.

This issue/the amount of required prop drilling potentially increases with each new feature (e.g #70, #51).
As mentiond by @planger in the discussion we ideally would like to keep handling of messenger events in a central place on both ends (i.e. the App for the webview part). So we should look into a different approach of sharing central state (and update functions/hooks) with different components.

React provides the Context API for this.
The App component could be refactored into a context provider that exposes the MemoryAppState and update functions/hooks.
Nested components can then simply access the provided context via the context property.

Additional information
I have created a draft PR for this proposal: #85

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

1 participant