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.

React Context not available in components

See original GitHub issue

Hey Dennis! Sorry for this neverending story, but I have another problem using the jsx/webpack adapter. 😕

Describe the bug We have a use case where we need data available to every component. To avoid “prop drilling” we want to make use of the Context-API for this.

I tried to make use of the react-server-render and react-client-render for this to make the context available to every component/variant in UIEngine. This looked good at first, since the Context-Provider showed up in the component tree: Bildschirmfoto 2019-08-10 um 15 42 59

Unfortunately, the actual context is not accessible in the components of the UIEngine. It appears like the context is not passed through to all the underlying components.

To Reproduce Steps to reproduce the behavior:

  1. A minimal example of the problem can be found here: https://github.com/MrAvantiC/uiengine-context
  2. Install dependencies and start development server
  3. See the console-ouput of the render() method in <Footer />

Expected behavior The context should be available in the <Footer /> component. I can confirm that the same code works in CRA/Next.js.

Kind regards, René

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
dennisreimanncommented, Aug 20, 2019

Status update: I got it working now 😃

Will clean up the code and test whether or not this helps with the hooks issue as well during the next days.

0reactions
dennisreimanncommented, Aug 22, 2019

v2.5 is available now and fixes this 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Context - React
Context provides a way to pass data through the component tree without ... some data needs to be accessible by many components at...
Read more >
React Context Not Working - Stack Overflow
It appears App is missing a contextTypes declaration. If contextTypes is not defined, then context will be an empty object.
Read more >
When to (Not) Use React Context API for State? - Jannik Wempe
The React Context API can be used to provide state to multiple components far away in the component tree. But is context always...
Read more >
How YOU can use the Context API in React.js to pubsub
Context is about sharing data to many components. The reason we need the Context API is that it's cumbersome to pass data from...
Read more >
Everything You Need to Know about React Context in 2022 ...
However, we don't want all the other components to re-render just because the context does. In this instance, the Main component consumes the ......
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