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

Syntax to integrate useContext with context function in Scala 3 #1074

Open
rpiaggio opened this issue Jun 14, 2022 · 1 comment
Open

Syntax to integrate useContext with context function in Scala 3 #1074

rpiaggio opened this issue Jun 14, 2022 · 1 comment

Comments

@rpiaggio
Copy link
Collaborator

In our apps, we use React context to store global implicits; eg: logger, effect type-class instances, web client backends, etc.

I'm thinking it would be nice to have something like, leveraging Scala 3's context functions:

  ScalaFnComponent
    .withHooks[Props]
    .useImplicitContext(MyContext.ctx)
    .useEffectBy( props =>
      // Theres an implicit `MyContext` in scope here; ie. this is a `MyContext ?=> Callback`
    )
    .useState(0)
    .render( (props, state) =>
      // Theres an implicit `MyContext` in scope here; ie. this is a `MyContext ?=> Callback`
    )

WDYT @japgolly ?

@japgolly
Copy link
Owner

Ooo cool idea! I like it! Unfortunately there's no chance I'm gonna have time to implement it, but a PR would be welcomed

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