Replace an existing page
Overview
This article describes how to replace an existing page in the app.
Replace an existing page
To replace an existing page, you need to create a new React component and add it to the app. To do this, follow these steps:
Open the
<package-id>/pages
folder or create a new one if it does not exist.Create a new React component in the
pages
folder. You can usepages/CustomPage.js
as a reference.const CustomPage = {
title: 'Custom Page',
blocks: [
{
name: 'namespace/custom-block',// custom block name
attributes: {
title: 'Title from app',
},
},
],
};
export default CustomPage;You need to register the block in the
blocks
folder. For more information, see Add a new block.Register the page in the
pages/index.js
file. For example, to replace theproductDetail
page, you need to add the following code:import CustomPage from './customPage';
const pages = {
'productDetail': CustomPage,
}
export { pages }Import the page in the
<package-id>/index.js
file.import {pages} from './pages/index';
Now the
productDetail
page is replaced with theCustomPage
component.