New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Best practice for using the new app bridge context #1798
Comments
👋 Thanks for opening your first issue. A contributor should give feedback soon. If you haven’t already, please check out the contributing guidelines. You can also join #polaris on the Shopify Partners Slack. |
Hi @dan-gamble we have an example in our docs explaining how to use our app bridge instance. Let me know if this helps! |
Hey @AndrewMusgrave, I did come across that but saw it was deprecated. I wondered how we should be using it going forward? I'm using the https://github.com/Shopify/shopify-app-node as a base and am currently doing: class MyApp extends App {
static async getInitialProps(server) {
const shopOrigin = server.ctx.query.shop;
return { shopOrigin };
}
render() {
const { Component, pageProps, shopOrigin } = this.props;
const app = createApp({
apiKey: 'API key from Shopify Partner Dashboard',
shopOrigin: shopOrigin,
});
return (
<Container>
<AppProvider>
<Provider
config={{
apiKey: API_KEY,
shopOrigin: shopOrigin,
forceRedirect: true
}}
>
<ApolloProvider client={localClient}>
<Component {...pageProps} appBridge={app} />
</ApolloProvider>
</Provider>
</AppProvider>
</Container>
);
}
} But feel like this is a little bit hacky and I'd have to prop drill to have access to the app bridge. Would appreciate any guidance on this but it could just be me being relatively naive to all of this. |
Looks like this is answered here but the issue i’m having is |
ping @timlayton as the man with context on uh, app-bridge context @dan-gamble it looks like The change to add Context to the root export is in master but hasn't been released just yet. For the moment you can do |
That’s awesome, thank you @tmlayton! I did dip in to my |
Looks like app-bridge-react 1.6.7 is now released, which includes Context in the root import. |
Hi Team, I have tried the above suggestion but Context and AppBridgeContext doesn't work. I would also like to know that since the fix is released for app-bridge-react 1.6.7 but it seems to be that the latest version is only 1.25.0. Is there another version of app-bridge? Would appreciate it if anybody can point me in the right direction and sorry if this is not the right place to ask. Thank you |
Look closer at those minor version numbers, 25 is larger than 6 :) The app-bridge team recently created a repo where you can report issues to them, For any further app-bridge issues you should open an issue in https://github.com/Shopify/shopify-app-bridge |
Hi Scott, Thanks for pointing that out. I guess the sleepless night figuring out this issue for the last couple of days made me slightly delirious. Thank you for the link. Will see if similar issue has been raised there or I'll raise one. |
Issue summary
Feel a tad silly with this one as I feel it is actually probably quite simple.
I'm looking to use the
Redirect
from the app-bridge. (import {Redirect} from '@shopify/app-bridge/actions'
).The issue I'm having is around the
app
part.Above it mentions doing:
But given we're already using the
<Provider>
I'd imagine this is accessible incontext
somewhere like it used to be?I've tried going down the
createApp
route but I'm not sure where I should be saving this to have it accessible globally. Given we're usingnext
I can't usewindow
for example.Apologies if this is the wrong place to ask this but the app-bridge repos are internal.
Edit
I've noticed when looking at the code of the React components from
@shopify/app-bridge-react
they use the internal context (var context_1 = require("../../context");
) so maybe this isn't globally accessible?The text was updated successfully, but these errors were encountered: