App reviews, troubleshooting, and recommendations
Hi guys.
My image here:
https://imgur.com/TVa9Z1e
My code here:
import React, { useState, useCallback } from 'react';
import { json } from '@remix-run/node';
import { authenticate } from '../shopify.server';
import { useLoaderData, useActionData } from '@remix-run/react';
import { Modal, TitleBar, useAppBridge } from '@shopify/app-bridge-react';
import { Page, BlockStack, Box, ChoiceList } from '@shopify/polaris';
// Loader.
export const loader = async ( { request, params } ) => {
const { admin, session } = await authenticate.admin( request );
const asset = new admin.rest.resources.Asset({ session: session });
asset.theme_id = 828155753; // Pass dynamic theme id here.
asset.key = "sections/index.liquid";
asset.value = "<img src='backsoon-postit.png'><p>We are busy updating the store for you and will be back within the hour.</p>";
const dataLoader = await asset.save({ update: true });
return json( { dataLoader } );
}
// Action.
export const action = async ( { request, params } ) => {
const { admin, session } = await authenticate.admin( request );
const asset = new admin.rest.resources.Asset({ session: session });
asset.theme_id = 828155753; // Pass dynamic theme id here.
asset.key = "sections/index.liquid";
asset.value = "<img src='backsoon-postit.png'><p>We are busy updating the store for you and will be back within the hour.</p>";
const actionData = await asset.save({ update: true });
return json( { actionData } );
}
// App.
const App = () => {
const shopify = useAppBridge();
const { dataLoader } = useLoaderData();
const { actionData } = useActionData();
const showModal = () => {
shopify.modal.show( 'my-modal' );
}
const [ selected, setSelected ] = useState( [] );
const handleChange = useCallback( value => setSelected( value ), [] );
const handleClick = () => {
console.log( selected );
}
return (
<Page
backAction={{ content: 'Sections', url: '#' }}
title="About section"
primaryAction={{ content: 'Add section to your theme', onAction: () => showModal() }} >
<Modal id="my-modal">
<TitleBar title="About section">
<button>Cancel</button>
<button onClick={ handleClick } variant="primary">Add section to your theme</button>
</TitleBar>
<Box padding="400">
<BlockStack gap="300">
<ChoiceList title="Themes:" choices={} selected={ selected } onChange={ handleChange } />
</BlockStack>
</Box>
</Modal>
</Page>
);
};
export default App;
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025