i'm looking shopify embedded app sdk , theres part have drop bit of javascript server-side variables. i'm using react engine, react-router , express.js.
<head> <script src="https://cdn.shopify.com/s/assets/external/app.js"></script> <script type="text/javascript"> shopifyapp.init({ apikey: 'your_app_api_key', shoporigin: 'https://current_logged_in_shop.myshopify.com' }); </script> </head> there way provide red.render(req.url, data) data, i'm not sure i'm supposed within component. there way access , change global shopifyapp variable within component?
i added shopify code componentdidmount of app component (top component in react-routes).
var layout = require('./layout.jsx'); var react = require('react'); var router = require('react-router'); module.exports = react.createclass({ componentdidmount: function(){ if(this.props.shopify){ shopifyapp.init({ apikey: this.props.shopify.apikey, shoporigin: this.props.shopify.shoporigin }) } }, render: function render() { return ( <layout {...this.props}> <router.routehandler {...this.props}/> </layout> ); } });
Comments
Post a Comment