Skip to content

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

@tortmayr

Description

@tortmayr

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions