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.

Context API support

See original GitHub issue

I’m attempting to utilize Vuera to create Gutenberg components for Wordpress using Vue. Overall I’m pretty happy with it, but I’m running into a limitation that severely restricts the set of things I can do:

Gutenberg utilizes the Context API that was introduced in React 16 extensively throughout its built-in editor components, particularly to manage when a block is “selected” vs not. This context does not appear to bridge across the vuera embed.

The high level structure I’m using returns a VueInReact wrapped component to Gutenberg, with my core Vue component handling my custom logic, and then as necessary embedding ReactInVue wrapped Gutenberg builtins.

So we have React (gutenberg, sets context) -> Vue (my code) ----> React (gutenberg, looks for context and doesn’t find it)

I’m happy to try to figure out/implement a fix for this, but would appreciate a pointer in the right direction if you have any ideas.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:9
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
akxcvcommented, Aug 7, 2018

Hi, yes, I’ve been thinking about how to bridge React context across vuera. I think that the best solution is to render inner React components via portals instead of ReactDOM.render (only in React > 16). This should preserve context if I’m not mistaken.

3reactions
kballcommented, Jul 30, 2018

Digging into this a more, I haven’t been able to track down how to programatically pull out a list of the Contexts that a component is embedded in.

Ideally I’d like to have the VueInReact wrapper grab that list (it’s a normal React component that has access to existing contexts), stash them on the Vue instance, and then teach ReactInVue to look up its parent tree within Vue for contexts and plug them into place again.

Maybe @gaearon or @acdlite could help point us in the right direction?

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 having to pass props down manually at every level. In a...
Read more >
React Context API: What is it and How it works?
The React Context API is a way for a React app to effectively produce global variables that can be passed around. This is...
Read more >
How to Work with the React Context API - Toptal
Let's refactor the app and demonstrate what it can do. In a few words, the Context API allows you to have a central...
Read more >
An Introduction To React's Context API - Smashing Magazine
In this article, you will learn how to use React's Context API which allows you to manage global application states in your React...
Read more >
React Context API: A deep dive with examples - LogRocket Blog
The new React Context API, introduced with React v.16.3, allows us to pass data through our component trees, giving our components the ability ......
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