We can achieve this in one way.
Go to \src\RouteHandler.js\src\RouteHandler.js
here sitecore.context
will be available.
changeChange the line like below, (This will pass context object to layout)
// Original line
return <Layout route={layoutData.route} />;
// Change this line
return <Layout route={layoutData.route} sitecoreContext={this.props.sitecoreContext} />;
Goto \src\Layout.js\src\Layout.js
, change the line below
// Original line
const Layout = ({ route }) => {
// Change this line
const Layout = ({ sitecoreContext, route }) => {
We can access the sitecoreContextsitecoreContext
object now.