question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

zero update propagation Context

See original GitHub issue

(Documentation only) feature request

There is a set of cases, when you need to read context only once. Read without any future update, so no subscription is needed - mount effect are a great example of this.

Some libraries already using this pattern, for example sweet-state uses readContext(“a hack”) to just get the data from React, in a same “no update” mode.

I think this pattern should be documented, but it seems a bit wrong to use useContext to do so, as long as there are some expectations about how useContext is working.

What do you think about useUntrackedContextSelector? The same useContextSelector, but “untracked”?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
theKasheycommented, Jul 27, 2019

Probably you are right, and I could solve the problem by creating two context - one with propagation, and another without. At least I would be able to use only built-in React functions. Or readContext hack.

1reaction
dai-shicommented, Jul 27, 2019

I understand your point. (I glanced react-sweet-state code using readContext before and I saw @JoviDeCroock 's code using React.useContext for that purpose.)

My preference is something like useReadContext. (no selector)

export const useReadContext = React.useContext;

However, I’m not sure if it should be a stable feature, because even if @gnoff 's RFC is accepted, this feature is not provided. (correct?) What do you think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

дэн on Twitter: "We want to fix the “deep update propagation ...
We want to fix the “deep update propagation” problem. But we don't want to pay the memory ... The new context API has...
Read more >
React Context Does Not Propagate Changes to Other ...
Now multiple contexts cannot communicate with each other. The solution here is to make use of wrapRootElement api in gatsby-ssr.js and ...
Read more >
The painful simplicity of context propagation in Go - YouTube
Context Propagation Part Deux: ctx context. Context in contextContext propagation is fundamental distributed tracing and modern observability ...
Read more >
Context Propagation makes OpenTelemetry awesome
OpenTelemetry #observability #tracing #metrics #logs #architecture #tutorial #tedsuoContext Propagation is a fundamental part of ...
Read more >
Trace Context - W3C
This specification includes editorial updates since the 6 February ... Trace context propagation passes along this unique identification.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found