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

Improve usage of context #3

Merged
merged 1 commit into from
Aug 21, 2024
Merged

Improve usage of context #3

merged 1 commit into from
Aug 21, 2024

Conversation

ghivert
Copy link
Owner

@ghivert ghivert commented Aug 21, 2024

create_context is barely usable right now, and is almost a React anti-pattern (because we'd have to pass the Context in every functions, which breaks the "no props-drilling" ability of Contexts). All Context in React should be declared once, at the top-level, and reuse after this.
In the future, create_context_ should still exists, in case anyone wants to build other abstractions on top of Context, while Redraw will push for the usage of context. Contrarily to Lustre, Redraw is effectful, and as such, accepts to trigger side-effects like this in components functions.

This PR fixes that behaviour, by emulating the same behaviour in Redraw.

@ghivert ghivert self-assigned this Aug 21, 2024
@ghivert ghivert force-pushed the fix/improve-usage-of-context branch 2 times, most recently from 01e00ec to 4c83770 Compare August 21, 2024 13:10
@ghivert ghivert force-pushed the fix/improve-usage-of-context branch from 4c83770 to 1a1aace Compare August 21, 2024 13:14
@ghivert ghivert merged commit 93d5acb into main Aug 21, 2024
1 check passed
@ghivert ghivert deleted the fix/improve-usage-of-context branch August 21, 2024 13:20
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.

1 participant