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.

(feature) Something like `context` in React

See original GitHub issue

Would it be possible to have something like context in React?

An object that you could set once on initialisation (in a custom render function at the top of your app) and then somehow access it later down in the component tree?

It’d be mostly for convenience, since I’m already passing an object (I think you call it data) down, and get my state from it.

I’d like to build something similar to react-router to be used with this library.

What do you think? is this even possible? a stupid idea?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
acstllcommented, Sep 8, 2017

I did something that could be it. It’s not something “on top” of picodom as @jbucaran first suggested, but “in it”, here’s a PR #27

It’s so simple that it’s a bit scary, haha. I’d love to know your thoughts.

0reactions
jorgebucarancommented, Sep 10, 2017

Closing as wontfix. #27

Read more comments on GitHub >

github_iconTop Results From Across the Web

Context - React
Context provides a way to share values like these between components without having to explicitly pass a prop through every level of the...
Read more >
React Context for Beginners – The Complete Guide (2021)
React context is an essential tool for every React developer to know. It lets you easily share state in your applications.
Read more >
How to Work with the React Context API - Toptal
What is context in React? React's context allows you to share information to any component, by storing it in a central place and...
Read more >
React Context API: A deep dive with examples - LogRocket Blog
According to the React docs, Context provides a way to pass data through the component tree from parent to child components, without having...
Read more >
A Guide to React Context and useContext() Hook
The context is used to manage global data, e.g. global state, theme, services, user settings, and more. In this post, you'll learn how...
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