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.

[scale] explore new context api for scale provider/consumers

See original GitHub issue

docs: https://reactjs.org/docs/context.html

In a typical React application, data is passed top-down (parent to child) via props, but this can be cumbersome for certain types of props (e.g. locale preference, UI theme) that are required by many components within an application. Context provides a way to share values like this between components without having to explicitly pass a prop through every level of the tree.

A common use case in data viz land is having multiple charts share the same time scale on a dashboard.

Currently you would have a parent component that controls the scale and passes it down through props. Thinking we could make <ScaleProvider/> and <ScaleConsumer/>.

Not sure how helpful it would be to have this live in vx might be fine letter this live in user land. Wouldn’t be too hard to use this convention without vx… maybe a better convention in a charting library vs library of low-level reusable component.

Just a thought, might be worth exploring.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
janbaykaracommented, Apr 10, 2018

I think it 100% makes sense to employ Context in code examples, to be encouraged, but beyond that I’m not sure it’s necessary to build into a library that calls itself a “collection of reusable low-level visualization components.” What would it do beyond wrapping Context?

Certainly, for passing canvas rendering context, it’d be great (and almost necessary).

1reaction
browniefedcommented, Apr 10, 2018

I don’t think passing rendering context via react context is a good idea. Doing it via a build step (using primitive, etc) allows for code to be eliminated. In the case of passing via context you’d be shipping native or unnecessary code all over.

I may be misunderstanding what you’re saying though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How (and when) to use React's new Context API
React Context is a way for a child component to access a value in a parent component. One familiar problem in React is...
Read more >
Context - React
Context provides a way to pass data through the component tree without having to pass props down manually at every level. In a...
Read more >
Provider Pattern with React Context API - Flexiple
React's provider pattern is a powerful concept. React uses provider pattern in Context API to share data across the tree descendant nodes.
Read more >
Get to Know React's New Context API - DigitalOcean
In this tutorial we will demonstrate using React's Context API to handle passing state between many layers of components.
Read more >
aggrid react
A fresh retake of the React API in Fable and a collection of high-quality ... Javascript answers related to “ag-grid react” how to...
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